https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111845

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Same with renamed vars, so that the long variable names don't make it
unreadable:

int a, b;
unsigned int c, d, e;

void
foo (int x)
{
  b += d;
  c += b < d;
  b += e = a < x;
  c += b;
  c += b < e;
}

I believe the above is equivalent to:
  e = a < x;
  unsigned c1;
  b = __builtin_addc (b, d, e, &c1);
  c = __builtin_addc (c, b, c1, &c1);
i.e. b is set to b + d + e where e is in [0, 1] range and c is set to c + b +
carry-out
from the b + d + e additions.

match_uaddc_usubc is called on the _17 = _30 + _31; addition in:
b.0_1 = b;
b.1_2 = (unsigned int) b.0_1;
d.2_3 = d;
_8 = .ADD_OVERFLOW (b.1_2, d.2_3);
_4 = REALPART_EXPR <_8>;
_14 = IMAGPART_EXPR <_8>;
_5 = _14 != 0;
_6 = (unsigned int) _5;
c.6_7 = c;
_31 = _6 + c.6_7;
a.7_9 = a;
_10 = a.7_9 < x_19(D);
_11 = (unsigned int) _10;
e = _11;
_29 = .ADD_OVERFLOW (_4, _11);
_12 = REALPART_EXPR <_29>;
_28 = IMAGPART_EXPR <_29>;
_13 = (int) _12;
b = _13;
_15 = _28 != 0;
_16 = (unsigned int) _15;
_30 = _12 + _16;
_17 = _30 + _31;
c = _17;
return;
and changes it:
@@ -12,14 +12,14 @@ a.7_9 = a;
 _10 = a.7_9 < x_19(D);
 _11 = (unsigned int) _10;
 e = _11;
+_27 = .UADDC (b.1_2, d.2_3, _11);
 _29 = .ADD_OVERFLOW (_4, _11);
-_12 = REALPART_EXPR <_29>;
-_28 = IMAGPART_EXPR <_29>;
+_12 = REALPART_EXPR <_27>;
 _13 = (int) _12;
 b = _13;
-_15 = _28 != 0;
-_16 = (unsigned int) _15;
 _30 = _12 + _16;
-_17 = _30 + _31;
+_26 = IMAGPART_EXPR <_27>;
+_25 = .UADDC (c.6_7, _12, _26);
+_17 = REALPART_EXPR <_25>;
 c = _17;
 return;
That again looks correct to me, except that the dead _30 = _12 + _16 statement
should have been removed as well but wasn't.  The bb contains still other dead
statements
but the _30 = _12 + _16; is the only problematic one, as it refers to released
SSA_NAME.  After a fast DCE I think the bb would turn into:
b.0_1 = b;
b.1_2 = (unsigned int) b.0_1;
d.2_3 = d;
c.6_7 = c;
a.7_9 = a;
_10 = a.7_9 < x_19(D);
_11 = (unsigned int) _10;
e = _11;
_27 = .UADDC (b.1_2, d.2_3, _11);
_12 = REALPART_EXPR <_27>;
_13 = (int) _12;
b = _13;
_26 = IMAGPART_EXPR <_27>;
_25 = .UADDC (c.6_7, _12, _26);
_17 = REALPART_EXPR <_25>;
c = _17;
return;

Reply via email to