https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56223
--- Comment #10 from Drea Pinski <pinskia at gcc dot gnu.org> ---
if (v_32 >= 0)
goto <bb 4>; [59.00%]
else
goto <bb 5>; [41.00%]
<bb 4> [local count: 627172604]:
s_34 = s_7 + v_32;
goto <bb 6>; [100.00%]
<bb 5> [local count: 435831803]:
s_33 = s_7 - v_32;
<bb 6> [local count: 1063004410]:
# s_35 = PHI <s_33(5), s_34(4)>
The way to handle this is detect
PLUS_EXPR/MINUS_EXPR and then factor out it as a plus_expr leaving behind `-
v_32`. Though for signed integers it gets more complex due to overflow as both
the new factored plus needs to cast to unsigned and so does the minus
expression.
But maybe we can just pattern match this one.
that is:
(simplify
(cond (ge @0 integer_zerop) (plus:c @0 @1) (minus @1 @0))
(with { tree utype = unsigned_type_for (type); }
(convert (plus:utype (absu:utype @0) (convert:utype @1))))