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

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Without the second redundant __builtin_add_overflow, we get
  a.0_1 = a;
  _7 = .ADD_OVERFLOW (a.0_1, 0);
  _2 = REALPART_EXPR <_7>;
  _3 = IMAGPART_EXPR <_7>;
  _4 = (_Bool) _3;
  c = _4;
  _5 = (_BitInt(8)) _2;
  b = _5;
before bitint lowering and lower it well, but the redundant call results in
  a.0_1 = a;
  _7 = .ADD_OVERFLOW (a.0_1, 0);
  _2 = IMAGPART_EXPR <_7>;
  _3 = (_Bool) _2;
  c = _3;
  _4 = REALPART_EXPR <_7>;
  _5 = (_BitInt(8)) _4;
  b = _5;
and optimizable_arith_overflow doesn't flag that as non-optimizable, so
the bitint lowering of .ADD_OVERFLOW happens in that case on the REALPART_EXPR
stmt.
optimizable_arith_overflow checks if both REALPART_EXPR and IMAGPART_EXPR
appear in the same bb (and that there are no other uses), but doesn't check
that REALPART_EXPR is first.  Either it should check that or perhaps allow it
first but require that it is not used in statements before the REALPART_EXPR.

Reply via email to