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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |103356

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
After my patch for PR 103356, this is fixed.

Before pre:
  _1 = a_4(D) ^ b_5(D);
  _2 = a_4(D) | b_5(D);
  if (_2 != 0)
    goto <bb 3>; [50.00%]
  else
    goto <bb 4>; [50.00%]

  <bb 3> [local count: 536870913]:
  _6 = a_4(D) & b_5(D);
  _9 = ~_6;

  <bb 4> [local count: 1073741824]:
  # iftmp.0_3 = PHI <_9(3), 0(2)>
  _7 = _1 == iftmp.0_3;


After PRE (after my patch):
  _1 = a_4(D) ^ b_5(D);
  _2 = a_4(D) | b_5(D);
  if (_2 != 0)
    goto <bb 4>; [50.00%]
  else
    goto <bb 3>; [50.00%]

  <bb 3> [local count: 536870912]:
  _10 = ~_1;
  goto <bb 5>; [100.00%]

  <bb 4> [local count: 536870913]:
//  _6 = a_4(D) & b_5(D);
 // _9 = ~_6;

  <bb 5> [local count: 1073741824]:
  # iftmp.0_3 = PHI <_9(4), 0(3)>
  # prephitmp_11 = PHI <_2(4), _10(3)>
  return prephitmp_11;

And then dom comes and does (because if (a|b) == 0 then both a and b are zero
and a^b == 0 and ~(a^b) is 1):
  <bb 2> [local count: 1073741824]:
  _2 = a_4(D) | b_5(D);
  if (_2 != 0)
    goto <bb 4>; [50.00%]
  else
    goto <bb 3>; [50.00%]

  <bb 3> [local count: 536870912]:
  _1 = 0;
  _10 = 1;

  <bb 4> [local count: 1073741824]:
  # prephitmp_11 = PHI <1(2), 1(3)>
  return 1;


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103356
[Bug 103356] bool0 == ~bool1 should simplify to bool1 ^ bool0

Reply via email to