[Bug tree-optimization/95924] Failure to optimize some bit magic to one of the operands

2023-08-21 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95924

--- Comment #3 from Andrew Pinski  ---
  _4 = (int) a_11(D);
  _5 = ~_4;
  _6 = (int) b_10(D);
  _7 = _5 & _6;

(simplify
 (bit_and:c (bit_not zero_one_valued_p@0) zero_one_valued_p@1)
 (bit_and @1 (bit_xor! @0 { build_one_cst (type); } )))

Might be enough.


  _4 = ~_3;
  # RANGE [irange] int [0, 1] MASK 0x1 VALUE 0x0
  _5 = (intD.9) b_8(D);
  # RANGE [irange] int [0, 1] MASK 0x1 VALUE 0x0
  _6 = _4 & _5;
  # RANGE [irange] int [0, 1]
  _15 = _6 ^ 1;

Or even:
(simplify
 (bit_xor (bit_and:c zero_one_valued_p@0 @1) integer_onep@2)
 (bit_or (bit_xor @0 @2) (bit_not! @1)))

Or:
(simplify
 (bit_xor (bit_and:c zero_one_valued_p@0 (bit_not @1)) integer_onep@2)
 (bit_or (bit_xor @0 @2) @1))

All of the above will work just trying to figure out which one would be better
here ...

[Bug tree-optimization/95924] Failure to optimize some bit magic to one of the operands

2021-07-24 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95924

Andrew Pinski  changed:

   What|Removed |Added

   Severity|normal  |enhancement
 Ever confirmed|0   |1
 Status|UNCONFIRMED |NEW
 CC||pinskia at gcc dot gnu.org
   Last reconfirmed||2021-07-25

--- Comment #2 from Andrew Pinski  ---
Confirmed.

I have a few patches which improve this but the following still needs to be
done:

  _3 = (int) a_9(D);
  _4 = ~_3;
  _5 = (int) b_8(D);
  _6 = _4 & _5;
  _7 = _6 == 0;

To:
 _3 = ~a_9(D)
 _7 = b_8(D) & _3

[Bug tree-optimization/95924] Failure to optimize some bit magic to one of the operands

2020-06-27 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95924

--- Comment #1 from Marc Glisse  ---
* If I replace ~a with !a, we manage to do everything with type bool. With ~a,
we don't, we stick to int.

* We don't handle a?b:false the same as a&&b.

* Even for (a | !b) && (!(!a & b) && a) we don't completely simplify, because
that would be replacing too many && with & (I think). If I manually replace one
&& with &, gcc manages.