public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/109938] New: ((a^c) & b) | a is not opimized to (b & c) | a
@ 2023-05-23 7:13 pinskia at gcc dot gnu.org
2023-05-23 8:09 ` [Bug tree-optimization/109938] " rguenth at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-23 7:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109938
Bug ID: 109938
Summary: ((a^c) & b) | a is not opimized to (b & c) | a
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Take:
```
int f(int a, int b, int c)
{
return ((a^c) & b) | a;
}
int f1(int a, int b, int c)
{
return ((a^c) | a) & (b|a);
}
int f2(int a, int b, int c)
{
return (b & c) | a;
}
```
These 3 functions should produce the same code.
Currently only f1 and f2 produces the decent code.
I noticed this while looking into PR 107887 and it is related to PR 100864.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/109938] ((a^c) & b) | a is not opimized to (b & c) | a
2023-05-23 7:13 [Bug tree-optimization/109938] New: ((a^c) & b) | a is not opimized to (b & c) | a pinskia at gcc dot gnu.org
@ 2023-05-23 8:09 ` rguenth at gcc dot gnu.org
2023-07-24 16:38 ` drross at redhat dot com
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-05-23 8:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109938
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2023-05-23
Ever confirmed|0 |1
Keywords| |missed-optimization
Status|UNCONFIRMED |NEW
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/109938] ((a^c) & b) | a is not opimized to (b & c) | a
2023-05-23 7:13 [Bug tree-optimization/109938] New: ((a^c) & b) | a is not opimized to (b & c) | a pinskia at gcc dot gnu.org
2023-05-23 8:09 ` [Bug tree-optimization/109938] " rguenth at gcc dot gnu.org
@ 2023-07-24 16:38 ` drross at redhat dot com
2023-08-11 8:20 ` cvs-commit at gcc dot gnu.org
2023-08-27 20:57 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: drross at redhat dot com @ 2023-07-24 16:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109938
Drew Ross <drross at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |drross at redhat dot com
--- Comment #2 from Drew Ross <drross at redhat dot com> ---
Expanding the pattern as follows: ((a^c) & b) | a --> (a | (a^c)) & (a | b)
allows other patterns to make the simplification. Namely (a | (a^c)) -> a | c,
then
(a | c) & (a | b) -> a | (b & c).
This type of expansion also generalizes nicely to patterns like ((a^c) | b) | a
-> a | b | c which can be done through a similar series of simplifications
after expanding the initial.
This brings up the infrastructure question for 3+ operators if it is worth it
to try all (or maybe most?) pairwise simplifications (for instance even in the
case of (a ^ c) | b | d | e | f | g | h | a).
Thoughts?
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/109938] ((a^c) & b) | a is not opimized to (b & c) | a
2023-05-23 7:13 [Bug tree-optimization/109938] New: ((a^c) & b) | a is not opimized to (b & c) | a pinskia at gcc dot gnu.org
2023-05-23 8:09 ` [Bug tree-optimization/109938] " rguenth at gcc dot gnu.org
2023-07-24 16:38 ` drross at redhat dot com
@ 2023-08-11 8:20 ` cvs-commit at gcc dot gnu.org
2023-08-27 20:57 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-08-11 8:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109938
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:9f9334921b7d2e7bdb7e03be1bf5a2caa8ed3ca9
commit r14-3144-g9f9334921b7d2e7bdb7e03be1bf5a2caa8ed3ca9
Author: Drew Ross <drross@redhat.com>
Date: Fri Aug 11 10:17:56 2023 +0200
match.pd: Implement missed optimization ((x ^ y) & z) | x -> (z & y) | x
[PR109938]
Adds a simplification for ((x ^ y) & z) | x to be folded into
(z & y) | x. Merges this simplification with ((x | y) & z) | x -> (z & y) |
x
to prevent duplicate pattern.
2023-08-11 Drew Ross <drross@redhat.com>
Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/109938
* match.pd (((x ^ y) & z) | x -> (z & y) | x): New simplification.
* gcc.c-torture/execute/pr109938.c: New test.
* gcc.dg/tree-ssa/pr109938.c: New test.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/109938] ((a^c) & b) | a is not opimized to (b & c) | a
2023-05-23 7:13 [Bug tree-optimization/109938] New: ((a^c) & b) | a is not opimized to (b & c) | a pinskia at gcc dot gnu.org
` (2 preceding siblings ...)
2023-08-11 8:20 ` cvs-commit at gcc dot gnu.org
@ 2023-08-27 20:57 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-27 20:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109938
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Target Milestone|--- |14.0
Status|NEW |RESOLVED
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-08-27 20:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-23 7:13 [Bug tree-optimization/109938] New: ((a^c) & b) | a is not opimized to (b & c) | a pinskia at gcc dot gnu.org
2023-05-23 8:09 ` [Bug tree-optimization/109938] " rguenth at gcc dot gnu.org
2023-07-24 16:38 ` drross at redhat dot com
2023-08-11 8:20 ` cvs-commit at gcc dot gnu.org
2023-08-27 20:57 ` 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).