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

--- Comment #5 from Dipesh Sharma <dipesh.sharma at amd dot com> ---
Created attachment 65275
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=65275&action=edit
Proposed patch for the optimization.

Opt not valid for the following cases:

- fp with -frounding-math.
- Integers with wrapping arithmetic and signed integer overflow.
- values to be folded must have single use otherwise we may end up adding an
extra ABS_EXPR.
e.g.
int gx, gy, mul;
void f (int x, int y)
{
  int ax = __builtin_abs (x);
  int ay = __builtin_abs (y);
  mul = ax * ay;
  gx = ax; // use of ax
  gy = ay; // use of ay
}


Let me know your thoughts on it or if I missed anything.

Reply via email to