https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70222
--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Example of lshiftrt SI DI SI 24 16 is e.g. gcc.c-torture/execute/20030408-1.c where we have SImode LSHIFTRT of (subreg:SI (ashift:DI (reg:DI 125) (const_int 8 [0x8])) 0) by 24, and is optimized into (subreg:SI (reg:DI 125) 0) shift down by 16, which is equivalent and we don't need masking. Another example is ashiftrt SI DI SI 28 31 in objc.dg/gnu-encoding/struct-layout-encoding-1_generate.c, where we have SImode LSHIFTRT of (ashiftrt:SI (subreg:SI (reg:DI 91 [ _12 ]) 0) (const_int 31 [0x1f])) by 28, and optimize this into: ASHIFTRT of (subreg:SI (reg:DI 91 [ _12 ]) 0) by 31. That would be wrong, if we didn't have outer_op of AND and outer_const 15, so we are fine too. So, looking at lines with result_mode == shift_mode && result_mode != mode && (orig_count != count || code != LSHIFTRT), I'm seeing: 2 @@@ 64 /tmp/ccf9ftjT.o test1 lshiftrt SI DI SI 24 16 2 @@@ 64 /tmp/ccq197Ke.ltrans0.o main lshiftrt SI DI SI 24 16 3 @@@ 64 /home/jakub/src/gcc/gcc/testsuite/gfortran.dg/function_optimize_11.f90 main ashiftrt SI DI SI 30 31 5 @@@ 64 /home/jakub/src/gcc/gcc/ada/makeutl.adb Makeutl.Queue.Hash ashiftrt SI DI SI 21 31 5 @@@ 64 /home/jakub/src/gcc/gcc/ada/makeutl.adb Makeutl.Queue.Marks.Get ashiftrt SI DI SI 21 31 5 @@@ 64 /home/jakub/src/gcc/gcc/ada/makeutl.adb Makeutl.Queue.Marks.Remove ashiftrt SI DI SI 21 31 5 @@@ 64 /home/jakub/src/gcc/gcc/ada/makeutl.adb Makeutl.Queue.Marks.Set ashiftrt SI DI SI 21 31 5 @@@ 64 /home/jakub/src/gcc/gcc/ada/makeutl.adb Makeutl.Queue.Marks.Tab.Getxnb ashiftrt SI DI SI 21 31 5 @@@ 64 /home/jakub/src/gcc/gcc/ada/makeutl.adb Makeutl.Queue.Marks.Tab.Presentxnb ashiftrt SI DI SI 21 31 5 @@@ 64 /home/jakub/src/gcc/gcc/ada/makeutl.adb Makeutl.Queue.Marks.Tab.Removexnb ashiftrt SI DI SI 21 31 6 @@@ 64 /tmp/ccJJfd4X.o foo lshiftrt SI DI SI 31 0 6 @@@ 64 /tmp/ccJJfd4X.o main lshiftrt SI DI SI 31 0 8 @@@ 64 /home/jakub/src/gcc/gcc/testsuite/gcc.c-torture/execute/20030408-1.c test1 lshiftrt SI DI SI 24 16 8 @@@ 64 pem_decrypt_test.go x509.CreateCertificate rotate QI DI QI 2 2 10 @@@ 64 /home/jakub/src/gcc/gcc/testsuite/objc.dg/gnu-encoding/struct-layout-encoding-1_generate.c generate_fields ashiftrt SI DI SI 28 31 16 @@@ 32 ../../../../libgo/go/crypto/x509/cert_pool.go x509.CreateCertificate rotate QI SI QI 2 2 16 @@@ 32 ../../../libgo/go/crypto/x509/cert_pool.go x509.CreateCertificate rotate QI SI QI 2 2 16 @@@ 32 pem_decrypt_test.go x509.CreateCertificate rotate QI SI QI 2 2 16 @@@ 64 ../../../libgo/go/crypto/x509/cert_pool.go x509.CreateCertificate rotate QI DI QI 2 2 18 @@@ 64 /home/jakub/src/gcc/gcc/testsuite/gcc.c-torture/execute/pr70222.c main lshiftrt SI DI SI 31 0 27 @@@ 64 /home/jakub/src/gcc/gcc/testsuite/gcc.c-torture/execute/pr70222.c foo lshiftrt SI DI SI 31 0 pr70222.c is the debugged case, ashiftrt SI DI SI 28 31 analyzed above, lshiftrt SI DI SI 24 16 too, and the rest are similar to the analyzed ones. Thus, my conclusion is that a) the #c6 patch doesn't hopefully trigger that often (only on the testcase during x86_64/i686 bootstrap/regtest), and b) haven't found another wrong-code issue. Thus I think the patch is, while perhaps incomplete, a step in the right direction.