[Bug tree-optimization/111543] `(a & b) & ~a` could be optimized before reassociation

2023-09-24 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111543

Andrew Pinski  changed:

   What|Removed |Added

 Resolution|--- |FIXED
   Target Milestone|--- |14.0
 Status|ASSIGNED|RESOLVED

--- Comment #5 from Andrew Pinski  ---
Fixed.

[Bug tree-optimization/111543] `(a & b) & ~a` could be optimized before reassociation

2023-09-24 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111543

--- Comment #4 from CVS Commits  ---
The trunk branch has been updated by Andrew Pinski :

https://gcc.gnu.org/g:1bf0cd05cb30889cae4b6cf06e80b7f3a13c40c1

commit r14-4241-g1bf0cd05cb30889cae4b6cf06e80b7f3a13c40c1
Author: Andrew Pinski 
Date:   Sat Sep 23 04:38:02 2023 +

MATCH: Add `(X & ~Y) & Y` and `(X | ~Y) | Y`

Even though this gets optimized by reassociation, catching it more often
will always be better.

Note the reason why I didn't add `(X ^ ~Y) ^ Y` is that it gets caught
by prefering `~(X ^ Y)` to `(X ^ ~Y)` which then it is caught by the
the pattern for `(X ^ Y) ^ Y` already.

PR tree-optimization/111543

gcc/ChangeLog:

* match.pd (`(X & ~Y) & Y`, `(X | ~Y) | Y`): New patterns.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/bitops-4.c: New test.

[Bug tree-optimization/111543] `(a & b) & ~a` could be optimized before reassociation

2023-09-23 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111543

Andrew Pinski  changed:

   What|Removed |Added

   Keywords||patch
URL||https://gcc.gnu.org/piperma
   ||il/gcc-patches/2023-Septemb
   ||er/631235.html

--- Comment #3 from Andrew Pinski  ---
Patch posted:
https://gcc.gnu.org/pipermail/gcc-patches/2023-September/631235.html

[Bug tree-optimization/111543] `(a & b) & ~a` could be optimized before reassociation

2023-09-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111543

--- Comment #2 from Andrew Pinski  ---
/* (X & ~Y) & Y -> 0 */
(simplify
 (bit_and:c (bit_and @0 @1) @2)
 (with { bool wascmp; }
  (if (bitwise_inverted_equal_p (@0, @2, wascmp)
   || bitwise_inverted_equal_p (@1, @2, wascmp))
   { wascmp ? constant_boolean_node (false, type) : build_zero_cst (type); })))
/* (X | ~Y) | Y -> -1 */
(simplify
 (bit_ior:c (bit_ior @0 @1) @2)
 (with { bool wascmp; }
  (if ((bitwise_inverted_equal_p (@0, @2, wascmp)
|| bitwise_inverted_equal_p (@1, @2, wascmp))
   && (!wascmp || element_precision (type) == 1))
   { build_all_ones_cst (TREE_TYPE (@0)); })))

[Bug tree-optimization/111543] `(a & b) & ~a` could be optimized before reassociation

2023-09-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111543

Andrew Pinski  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED

[Bug tree-optimization/111543] `(a & b) & ~a` could be optimized before reassociation

2023-09-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111543

Andrew Pinski  changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |pinskia at gcc dot 
gnu.org
 Status|UNCONFIRMED |NEW
 Ever confirmed|0   |1
   Last reconfirmed||2023-09-22

--- Comment #1 from Andrew Pinski  ---
Mine.