public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug tree-optimization/115224] New: (a ^ 1) & (a ^ ~1) is not optimized to 0 at the gimplelevel @ 2024-05-25 4:59 pinskia at gcc dot gnu.org 2024-05-25 4:59 ` [Bug tree-optimization/115224] " pinskia at gcc dot gnu.org ` (4 more replies) 0 siblings, 5 replies; 6+ messages in thread From: pinskia at gcc dot gnu.org @ 2024-05-25 4:59 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115224 Bug ID: 115224 Summary: (a ^ 1) & (a ^ ~1) is not optimized to 0 at the gimplelevel Product: gcc Version: 15.0 Status: UNCONFIRMED Keywords: missed-optimization, TREE Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Take: ``` int f1(int a) { return (a ^ -2) & (a ^ 1); } int f2(int a, int b) { b = 1; return (a ^ b) & (a ^ ~b); } int f3(int a, int b) { b = 1; int t = a ^b; int t1 = a ^ ~b; return t & t1; } ``` These all should be the same, GCC does optimize all to 0 but f1 and f3 is only done on the RTL level. This can be solved by improving bitwise_inverted_equal_p to see that `(a ^ CST)` and `(a ^ (~CST))` are inverse of each other. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/115224] (a ^ 1) & (a ^ ~1) is not optimized to 0 at the gimplelevel 2024-05-25 4:59 [Bug tree-optimization/115224] New: (a ^ 1) & (a ^ ~1) is not optimized to 0 at the gimplelevel pinskia at gcc dot gnu.org @ 2024-05-25 4:59 ` pinskia at gcc dot gnu.org 2024-05-27 1:05 ` pinskia at gcc dot gnu.org ` (3 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: pinskia at gcc dot gnu.org @ 2024-05-25 4:59 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115224 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot gnu.org Ever confirmed|0 |1 Last reconfirmed| |2024-05-25 Status|UNCONFIRMED |ASSIGNED --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- MIne. found working on the `a - b` vs `b - a` patch. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/115224] (a ^ 1) & (a ^ ~1) is not optimized to 0 at the gimplelevel 2024-05-25 4:59 [Bug tree-optimization/115224] New: (a ^ 1) & (a ^ ~1) is not optimized to 0 at the gimplelevel pinskia at gcc dot gnu.org 2024-05-25 4:59 ` [Bug tree-optimization/115224] " pinskia at gcc dot gnu.org @ 2024-05-27 1:05 ` pinskia at gcc dot gnu.org 2024-05-29 15:54 ` cvs-commit at gcc dot gnu.org ` (2 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: pinskia at gcc dot gnu.org @ 2024-05-27 1:05 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115224 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- URL| |https://gcc.gnu.org/piperma | |il/gcc-patches/2024-May/652 | |752.html Keywords| |patch --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- https://gcc.gnu.org/pipermail/gcc-patches/2024-May/652752.html ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/115224] (a ^ 1) & (a ^ ~1) is not optimized to 0 at the gimplelevel 2024-05-25 4:59 [Bug tree-optimization/115224] New: (a ^ 1) & (a ^ ~1) is not optimized to 0 at the gimplelevel pinskia at gcc dot gnu.org 2024-05-25 4:59 ` [Bug tree-optimization/115224] " pinskia at gcc dot gnu.org 2024-05-27 1:05 ` pinskia at gcc dot gnu.org @ 2024-05-29 15:54 ` cvs-commit at gcc dot gnu.org 2024-05-29 16:00 ` pinskia at gcc dot gnu.org 2024-05-30 3:56 ` pinskia at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2024-05-29 15:54 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115224 --- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Andrew Pinski <pinskia@gcc.gnu.org>: https://gcc.gnu.org/g:547143df5aa0960fb149a26933dad7ca1c363afb commit r15-908-g547143df5aa0960fb149a26933dad7ca1c363afb Author: Andrew Pinski <quic_apinski@quicinc.com> Date: Sun May 26 17:38:37 2024 -0700 match: Add support for `a ^ CST` to bitwise_inverted_equal_p [PR115224] While looking into something else, I noticed that `a ^ CST` needed to be special casing to bitwise_inverted_equal_p as it would simplify to `a ^ ~CST` for the bitwise not. Bootstrapped and tested on x86_64-linux-gnu with no regressions. PR tree-optimization/115224 gcc/ChangeLog: * generic-match-head.cc (bitwise_inverted_equal_p): Add `a ^ CST` case. * gimple-match-head.cc (gimple_bit_xor_cst): New declaration. (gimple_bitwise_inverted_equal_p): Add `a ^ CST` case. * match.pd (bit_xor_cst): New match. (maybe_bit_not): Add bit_xor_cst case. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/bitops-8.c: New test. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com> ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/115224] (a ^ 1) & (a ^ ~1) is not optimized to 0 at the gimplelevel 2024-05-25 4:59 [Bug tree-optimization/115224] New: (a ^ 1) & (a ^ ~1) is not optimized to 0 at the gimplelevel pinskia at gcc dot gnu.org ` (2 preceding siblings ...) 2024-05-29 15:54 ` cvs-commit at gcc dot gnu.org @ 2024-05-29 16:00 ` pinskia at gcc dot gnu.org 2024-05-30 3:56 ` pinskia at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: pinskia at gcc dot gnu.org @ 2024-05-29 16:00 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115224 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution|--- |FIXED Target Milestone|--- |15.0 --- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Fixed. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/115224] (a ^ 1) & (a ^ ~1) is not optimized to 0 at the gimplelevel 2024-05-25 4:59 [Bug tree-optimization/115224] New: (a ^ 1) & (a ^ ~1) is not optimized to 0 at the gimplelevel pinskia at gcc dot gnu.org ` (3 preceding siblings ...) 2024-05-29 16:00 ` pinskia at gcc dot gnu.org @ 2024-05-30 3:56 ` pinskia at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: pinskia at gcc dot gnu.org @ 2024-05-30 3:56 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115224 --- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> --- *** Bug 113072 has been marked as a duplicate of this bug. *** ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-05-30 3:56 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2024-05-25 4:59 [Bug tree-optimization/115224] New: (a ^ 1) & (a ^ ~1) is not optimized to 0 at the gimplelevel pinskia at gcc dot gnu.org 2024-05-25 4:59 ` [Bug tree-optimization/115224] " pinskia at gcc dot gnu.org 2024-05-27 1:05 ` pinskia at gcc dot gnu.org 2024-05-29 15:54 ` cvs-commit at gcc dot gnu.org 2024-05-29 16:00 ` pinskia at gcc dot gnu.org 2024-05-30 3:56 ` pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).