https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83424
Bug ID: 83424 Summary: [8 Regression] wrong code with -O -fno-tree-ccp -fno-tree-coalesce-vars Product: gcc Version: 8.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: zsojka at seznam dot cz Target Milestone: --- Host: x86_64-pc-linux-gnu Target: x86_64-pc-linux-gnu Created attachment 42882 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42882&action=edit reduced testcase Output: $ x86_64-pc-linux-gnu-gcc -O -fno-tree-ccp -fno-tree-coalesce-vars testcase.c $ ./a.out Aborted $ x86_64-pc-linux-gnu-gcc -v Using built-in specs. COLLECT_GCC=/repo/gcc-trunk/binary-latest-amd64/bin/x86_64-pc-linux-gnu-gcc COLLECT_LTO_WRAPPER=/repo/gcc-trunk/binary-trunk-255624-checking-yes-rtl-df-extra-nobootstrap-nographite-amd64/bin/../libexec/gcc/x86_64-pc-linux-gnu/8.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /repo/gcc-trunk//configure --enable-languages=c,c++ --enable-valgrind-annotations --disable-nls --enable-checking=yes,rtl,df,extra --disable-bootstrap --without-cloog --without-ppl --without-isl --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --target=x86_64-pc-linux-gnu --with-ld=/usr/bin/x86_64-pc-linux-gnu-ld --with-as=/usr/bin/x86_64-pc-linux-gnu-as --disable-libstdcxx-pch --prefix=/repo/gcc-trunk//binary-trunk-255624-checking-yes-rtl-df-extra-nobootstrap-nographite-amd64 Thread model: posix gcc version 8.0.0 20171214 (experimental) (GCC) Tested revisions: r255624 - FAIL r255606 - FAIL r255553 - FAIL r255386 - OK foo() is optimized to just "retn" This seems to go wrong in .combine: ... Trying 21, 11 -> 22: 21: {r112:TI=-r101:TI;clobber flags:CC;} REG_UNUSED flags:CC 11: r98:QI=~r105:QI REG_DEAD r105:QI REG_EQUAL ~[`b'] 22: {r113:QI=r98:QI*r112:TI#0;clobber flags:CC;} REG_DEAD r112:TI REG_DEAD r98:QI REG_UNUSED flags:CC Failed to match this instruction: (parallel [ (set (reg:QI 113 [ xD.1900 ]) (mult:QI (plus:QI (reg:QI 105 [ bD.1896 ]) (const_int 1 [0x1])) (subreg:QI (reg/v:TI 101 [ pD.1897 ]) 0))) (clobber (reg:CC 17 flags)) ]) Failed to match this instruction: (set (reg:QI 113 [ xD.1900 ]) (mult:QI (plus:QI (reg:QI 105 [ bD.1896 ]) (const_int 1 [0x1])) (subreg:QI (reg/v:TI 101 [ pD.1897 ]) 0))) Successfully matched this instruction: (set (reg:QI 112) (plus:QI (reg:QI 105 [ bD.1896 ]) (const_int 1 [0x1]))) Successfully matched this instruction: (set (reg:QI 113 [ xD.1900 ]) (mult:QI (reg:QI 112) (subreg:QI (reg/v:TI 101 [ pD.1897 ]) 0))) allowing combination of insns 11, 21 and 22 original costs 4 + 8 + 24 = 36 replacement costs 4 + 24 = 28 deferring deletion of insn with uid = 11. modifying insn i2 21: {r112:QI=r105:QI+0x1;clobber flags:CC;} REG_UNUSED flags:CC REG_DEAD r105:QI deferring rescan insn with uid = 21. modifying insn i3 22: {r113:QI=r112:QI*r101:TI#0;clobber flags:CC;} REG_DEAD r101:TI REG_UNUSED flags:CC REG_DEAD r112:QI deferring rescan insn with uid = 22. ... It seems the REG_DEAD r101:TI note should not be there, this r101 is later used by insn 29.