public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/109878] New: missed simplifications of MAX<a&CST0,a&CST1> and MIN<a&CST0,a&CST1>
@ 2023-05-16 19:56 pinskia at gcc dot gnu.org
2023-09-08 22:51 ` [Bug tree-optimization/109878] " pinskia at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-16 19:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109878
Bug ID: 109878
Summary: missed simplifications of MAX<a&CST0,a&CST1> and
MIN<a&CST0,a&CST1>
Product: gcc
Version: 14.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 max_and(int a, int b)
{
b = a & 3;
a = a & 1;
if (b > a)
return b;
else
return a;
}
int min_and(int a, int b)
{
b = a & 3;
a = a & 1;
if (b < a)
return b;
else
return a;
}
```
max_and should just be optimized to `a&3` while min_and should be just
optimized to `a&1` The general rule is:
MAX<a&CST0, a & CST1> -> a & CST0 IFF CST0 &CST1 == CST1, that is CST1 is a
true subset of CST0.
I found this on accident while thinking about some generated code in
insn-automata.cc on x86_64.
MIN<a&CST0, a & CST1> -> a & CST0 IFF CST0&CST1 == CST0, that is CST0 is a true
subset of CST1.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug tree-optimization/109878] missed simplifications of MAX<a&CST0,a&CST1> and MIN<a&CST0,a&CST1>
2023-05-16 19:56 [Bug tree-optimization/109878] New: missed simplifications of MAX<a&CST0,a&CST1> and MIN<a&CST0,a&CST1> pinskia at gcc dot gnu.org
@ 2023-09-08 22:51 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-08 22:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109878
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot gnu.org
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2023-09-08
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Mine.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-09-08 22:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-16 19:56 [Bug tree-optimization/109878] New: missed simplifications of MAX<a&CST0,a&CST1> and MIN<a&CST0,a&CST1> pinskia at gcc dot gnu.org
2023-09-08 22:51 ` [Bug tree-optimization/109878] " 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).