https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43892
--- Comment #32 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #5)
> No.
>
> Actually compilable testcase:
>
> typedef unsigned int u32;
>
> u32
> add32carry(u32 sum, u32 x)
> {
> u32 z = sum + x;
> if (sum + x < x)
> z++;
> return z;
> }
>
> u32
> loop(u32 *buf, int len)
> {
> u32 sum = 0;
> for(; len; --len)
> sum = add32carry(sum, *++buf);
> return sum;
> }
Note on the trunk this code is recognized at least on the gimple level as add
with overflow and does:
_7 = .ADD_OVERFLOW (sum_2(D), x_3(D));
z_4 = REALPART_EXPR <_7>;
_8 = IMAGPART_EXPR <_7>;
if (_8 != 0)
goto <bb 3>; [50.00%]
else
goto <bb 4>; [50.00%]
<bb 3> [local count: 536870913]:
z_5 = z_4 + 1;
<bb 4> [local count: 1073741824]:
# z_1 = PHI <z_4(2), z_5(3)>
---- CUT ---
So it is more about the back-end of PowerPC at this point.