public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/115055] New: reassociation should use match-and-simplify
@ 2024-05-12 21:59 pinskia at gcc dot gnu.org
2024-05-13 9:49 ` [Bug tree-optimization/115055] " rguenth at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-05-12 21:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115055
Bug ID: 115055
Summary: reassociation should use match-and-simplify
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Keywords: missed-optimization
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 c)
{
int b = a & c;
return (a == 0) & b;
}
```
This should be optimized to 0 but currently does not.
There is a match pattern (via PR 111431) which is able to handle `a & (a == 0)`
into `0`. reassociation knows how to handle `a & a` but it seems like if while
doing reassociation, we should be to try to use match-and-simplify to simplify
the f here.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug tree-optimization/115055] reassociation should use match-and-simplify
2024-05-12 21:59 [Bug tree-optimization/115055] New: reassociation should use match-and-simplify pinskia at gcc dot gnu.org
@ 2024-05-13 9:49 ` rguenth at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-13 9:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115055
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2024-05-13
Ever confirmed|0 |1
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
b_5 = a_3(D) & c_4(D);
_1 = a_3(D) == 0;
_2 = (int) _1;
_6 = b_5 & _2;
return _6;
I believe reassoc doesn't see that a and (int)(a == 0) are "related" when
ranking ops of the AND, so it fails to appropriately order them and thus
trigger the simplification. We definitely want to avoid doing n^2
matching combos of all AND operands.
So confirmed, but not necessarily confirming the proposed solution.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-05-13 9:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-12 21:59 [Bug tree-optimization/115055] New: reassociation should use match-and-simplify pinskia at gcc dot gnu.org
2024-05-13 9:49 ` [Bug tree-optimization/115055] " rguenth 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).