https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83628
--- Comment #6 from Uroš Bizjak <ubizjak at gmail dot com> ---
On a related note, gcc-5 (-O2) was able to also simplify:
int test (int a, int b, int c)
{
return (a < b) * 4 + c;
}
cmplt $16,$17,$17
s4addl $17,$18,$0
ret $31,($26),1
where gcc-8 emits:
cmplt $16,$17,$0
s4addq $0,0,$0
addl $0,$18,$0
ret $31,($26),1
gcc-5 is able to if-convert to:
(insn 30 10 15 2 (set (reg:DI 70 [ D.1498 ])
(if_then_else:DI (ne (reg:DI 76)
(const_int 0 [0]))
(const_int 4 [0x4])
(const_int 0 [0]))) cmp1.c:5 161 {*movdicc_internal}
(nil))
which is later combined with:
(insn 15 30 16 2 (set (reg:SI 77 [ D.1498 ])
(plus:SI (subreg/s/u:SI (reg:DI 70 [ D.1498 ]) 0)
(subreg/s/u:SI (reg/v:DI 75 [ c ]) 0))) cmp1.c:5 3 {addsi3}
(expr_list:REG_DEAD (reg/v:DI 75 [ c ])
(expr_list:REG_DEAD (reg:DI 70 [ D.1498 ])
(nil))))
to:
Trying 30 -> 15:
Successfully matched this instruction:
(set (reg:SI 77 [ D.1498 ])
(plus:SI (mult:SI (subreg:SI (reg:DI 76) 0)
(const_int 4 [0x4]))
(reg:SI 18 $18 [ c ])))
gcc-8 is not able to if-convert...