https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123116
--- Comment #1 from Uroš Bizjak <ubizjak at gmail dot com> ---
combine pass does:
for f5:
Trying 22 -> 12:
22: {r101:SI=[`c']!=0-0x1a;clobber flags:CC;}
REG_UNUSED flags:CC
12: {[`v']=[`v']+r101:SI;clobber flags:CC;}
REG_DEAD r101:SI
REG_UNUSED flags:CC
Successfully matched this instruction:
(parallel [
(set (mem/c:SI (symbol_ref:DI ("v") [flags 0x2] <var_decl
0x7fd5843c9e40 v>) [1 v+0 S4 A32])
(plus:SI (plus:SI (ne:SI (mem/c:QI (symbol_ref:DI ("c") [flags 0x2]
<var_decl 0x7fd5843c9ed8 c>) [0 c+0 S1 A8])
(const_int 0 [0]))
(mem/c:SI (symbol_ref:DI ("v") [flags 0x2] <var_decl
0x7fd5843c9e40 v>) [1 v+0 S4 A32]))
(const_int -26 [0xffffffffffffffe6])))
(clobber (reg:CC 17 flags))
])
allowing combination of insns 22 and 12
That combines to *addsi3_ne.
But for f6:
Trying 6, 7, 8 -> 9:
6: flags:CC=cmp([`c'],0x1)
7: {r103:SI={(ltu(flags:CC,0))?0xffffffffffffffff:0};clobber flags:CC;}
REG_DEAD flags:CC
REG_UNUSED flags:CC
8: {r103:SI=r103:SI-0x19;clobber flags:CC;}
REG_UNUSED flags:CC
9: {[`v']=[`v']+r103:SI;clobber flags:CC;}
REG_DEAD r103:SI
REG_UNUSED flags:CC
Failed to match this instruction:
(parallel [
(set (mem/c:SI (symbol_ref:DI ("v") [flags 0x2] <var_decl
0x7fd5843c9e40 v>) [1 v+0 S4 A32])
(plus:SI (plus:SI (if_then_else:SI (eq:SI (mem/c:QI (symbol_ref:DI
("c") [flags 0x2] <var_decl 0x7fd5843c9ed8 c>) [0 c+0 S1 A8])
(const_int 0 [0]))
(const_int -1 [0xffffffffffffffff])
(const_int 0 [0]))
(mem/c:SI (symbol_ref:DI ("v") [flags 0x2] <var_decl
0x7fd5843c9e40 v>) [1 v+0 S4 A32]))
(const_int -25 [0xffffffffffffffe7])))
(clobber (reg:CC 17 flags))
])
We can add some additional patterns, similar to *{add,sub}<mode>3_{eq,ne}{,_0}
that will handle if_then_else RTX around eq.