https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110042
Bug ID: 110042 Summary: [14 Regression] missed cmov optimization after r14-1014-gc5df248509b489364c573e8 Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Target: aarch64-linux-gnu Take: ``` unsigned f1(int t, int t1) { int tt = 0; if(t) tt = (t1&0x8)!=0; return tt; } ``` On aarch64 we should produce: ``` cmp w0, 0 ubfx x0, x1, 3, 1 csel w0, w0, wzr, ne ret ``` But on the trunk we get: ``` cbz w0, .L3 ubfx x0, x1, 3, 1 ret .p2align 2,,3 .L3: mov w0, 0 ret ``` The difference in the IR is: old: ``` (insn 11 10 12 3 (set (reg:SI 97) (lshiftrt:SI (reg/v:SI 96 [ t1 ]) (const_int 3 [0x3]))) "/app/example.cpp":7:18 782 {*aarch64_lshr_sisd_or_int_si3} (expr_list:REG_DEAD (reg/v:SI 96 [ t1 ]) (nil))) (insn 12 11 25 3 (set (reg:SI 94 [ <retval> ]) (and:SI (reg:SI 97) (const_int 1 [0x1]))) "/app/example.cpp":7:18 533 {andsi3} (expr_list:REG_DEAD (reg:SI 97) (nil))) ``` new: ``` (insn 11 10 12 3 (set (subreg:DI (reg:SI 97) 0) (zero_extract:DI (subreg:DI (reg/v:SI 96 [ t1 ]) 0) (const_int 1 [0x1]) (const_int 3 [0x3]))) "/app/example.cpp":7:18 832 {*extzvdi} (expr_list:REG_DEAD (reg/v:SI 96 [ t1 ]) (nil))) (insn 12 11 24 3 (set (reg:SI 94 [ <retval> ]) (reg:SI 97)) "/app/example.cpp":8:10 64 {*movsi_aarch64} (expr_list:REG_DEAD (reg:SI 97) (nil))) ``` noce_try_cmove_arith handles the old one but not the new one for some reason: ``` if-conversion succeeded through noce_try_cmove_arith ``