https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94846
Uroš Bizjak <ubizjak at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Last reconfirmed| |2020-11-25 Status|UNCONFIRMED |NEW CC| |rguenth at gcc dot gnu.org Component|rtl-optimization |tree-optimization --- Comment #3 from Uroš Bizjak <ubizjak at gmail dot com> --- This looks like a tree-optimization problem. A store to *p_5(D) could sink all the way to bb5. RTL gets expanded from: ... if (_10 != 0) goto <bb 4>; [50.00%] else goto <bb 3>; [50.00%] <bb 3> [local count: 536870912]: *p_5(D) = _1; goto <bb 5>; [100.00%] <bb 4> [local count: 536870913]: _2 = _1 + 1; *p_5(D) = _2; <bb 5> [local count: 1073741824]: # prephitmp_11 = PHI <_1(3), _2(4)> return prephitmp_11; ifcvt RTL pass (_.ce1) is unable to convert: ... 17: r86:SI=r89:SI REG_DEAD r89:SI 18: flags:CCZ=cmp(r85:SI,0) REG_DEAD r85:SI 19: pc={(flags:CCZ!=0)?L24:pc} REG_DEAD flags:CCZ REG_BR_PROB 536870916 20: NOTE_INSN_BASIC_BLOCK 5 21: [r87:DI]=r89:SI REG_DEAD r87:DI ; pc falls through to BB 7 24: L24: 25: NOTE_INSN_BASIC_BLOCK 6 26: {r86:SI=r89:SI+0x1;clobber flags:CC;} REG_UNUSED flags:CC 27: [r87:DI]=r86:SI REG_DEAD r87:DI 32: L32: 35: NOTE_INSN_BASIC_BLOCK 7 ... IF-THEN-ELSE-JOIN block found, pass 2, test 2, then 5, else 6, join 7 === In case p is not a pointer, RTL optimizers start with: ... if (_8 != 0) goto <bb 3>; [50.00%] else goto <bb 4>; [50.00%] <bb 3> [local count: 536870913]: p_5 = p_4 + 1; <bb 4> [local count: 1073741824]: # p_1 = PHI <p_4(2), p_5(3)> return p_1; and RTL ifcvt pass is able to convert this form to addcc: IF-THEN-JOIN block found, pass 2, test 2, then 5, join 6 if-conversion succeeded through noce_try_addcc