https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103775
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Component|target |rtl-optimization Ever confirmed|0 |1 Status|UNCONFIRMED |NEW Last reconfirmed| |2021-12-20 Keywords|ice-on-valid-code | CC| |pinskia at gcc dot gnu.org --- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (insn 12 9 13 2 (set (reg:SI 93 [ _2 ]) (zero_extend:SI (mem/c:QI (plus:DI (reg/f:DI 65 ap) (const_int 16 [0x10])) [1 u128_1+0 S1 A128]))) "/app/example.cpp":5:35 117 {*zero_extendqisi2_aarch64} (nil)) Auto-increment then turns it into: (insn 39 9 12 2 (set (reg/f:DI 114) (reg/f:DI 65 ap)) "/app/example.cpp":5:35 -1 (nil)) (insn 12 39 13 2 (set (reg:SI 93 [ _2 ]) (zero_extend:SI (mem/c:QI (pre_modify:DI (reg/f:DI 114) (plus:DI (reg/f:DI 114) (const_int 16 [0x10]))) [1 u128_1+0 S1 A128]))) "/app/example.cpp":5:35 117 {*zero_extendqisi2_aarch64} (expr_list:REG_INC (reg/f:DI 114) (nil))) But this does not make sense as the result of the modify is not used afterwards. found pre add(17) r[115]=r[65]+20 16: r114:DI=ap:DI+0x10 REG_UNUSED r114:DI 15: r95:SI=r113:DI#0 REG_DEAD r113:DI 14: r113:DI=clrsb(r112:DI) REG_DEAD r112:DI 13: r112:DI=zero_extend(r93:SI) 12: r93:SI=zero_extend([ap:DI+0x10]) 12: r93:SI=zero_extend([ap:DI+0x10]) found mem(12) *(r[65]+16) 16: r114:DI=ap:DI+0x10 REG_UNUSED r114:DI found post add(16) r[114]=r[65]+16 hmm before auto-increment: (insn 16 15 17 2 (set (reg/f:DI 114) (plus:DI (reg/f:DI 65 ap) (const_int 16 [0x10]))) "/app/example.cpp":6:3 124 {*adddi3_aarch64} (nil)) (insn 17 16 18 2 (set (reg/f:DI 115) (plus:DI (reg/f:DI 65 ap) (const_int 20 [0x14]))) "/app/example.cpp":6:3 124 {*adddi3_aarch64} (expr_list:REG_DEAD (reg/f:DI 114) (nil))) 114 is dead even before this. Oh this is because at -Og we are not running DCE. I think there is some DF not being updated before auto-increment too.