public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/112093] New: (X & Y) < X (unsigned) and (X & Y) != X should produce the same code
@ 2023-10-26 2:48 pinskia at gcc dot gnu.org
2023-10-26 2:48 ` [Bug tree-optimization/112093] " pinskia at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-26 2:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112093
Bug ID: 112093
Summary: (X & Y) < X (unsigned) and (X & Y) != X should produce
the same code
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Keywords: missed-optimization
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 f(unsigned a, unsigned b)
{
return (a&b) < a;
}
int f1(unsigned a, unsigned b)
{
return (a&b) != a;
}
int g(unsigned a, unsigned b)
{
return (a&b) >= a;
}
int g1(unsigned a, unsigned b)
{
return (a&b) == a;
}
```
f and f1 are equivalent but don't produce the same result.
Likewise for g and g1.
This is a Canonical issue really.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/112093] (X & Y) < X (unsigned) and (X & Y) != X should produce the same code
2023-10-26 2:48 [Bug tree-optimization/112093] New: (X & Y) < X (unsigned) and (X & Y) != X should produce the same code pinskia at gcc dot gnu.org
@ 2023-10-26 2:48 ` pinskia at gcc dot gnu.org
2023-10-26 2:52 ` pinskia at gcc dot gnu.org
2023-11-04 21:10 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-26 2:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112093
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/112093] (X & Y) < X (unsigned) and (X & Y) != X should produce the same code
2023-10-26 2:48 [Bug tree-optimization/112093] New: (X & Y) < X (unsigned) and (X & Y) != X should produce the same code pinskia at gcc dot gnu.org
2023-10-26 2:48 ` [Bug tree-optimization/112093] " pinskia at gcc dot gnu.org
@ 2023-10-26 2:52 ` pinskia at gcc dot gnu.org
2023-11-04 21:10 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-26 2:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112093
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=101590
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
| has a similar issue:
```
int f_or(unsigned a, unsigned b)
{
return (a|b) <= a;
}
int f1_or(unsigned a, unsigned b)
{
return (a|b) == a;
}
int g_or(unsigned a, unsigned b)
{
return (a|b) > a;
}
int g1_or(unsigned a, unsigned b)
{
return (a|b) != a;
}
```
Note for other comparisons, see PR 101590 which I am about to submit a patch
for since they simplify down to a constant.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/112093] (X & Y) < X (unsigned) and (X & Y) != X should produce the same code
2023-10-26 2:48 [Bug tree-optimization/112093] New: (X & Y) < X (unsigned) and (X & Y) != X should produce the same code pinskia at gcc dot gnu.org
2023-10-26 2:48 ` [Bug tree-optimization/112093] " pinskia at gcc dot gnu.org
2023-10-26 2:52 ` pinskia at gcc dot gnu.org
@ 2023-11-04 21:10 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-04 21:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112093
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2023-11-04
Ever confirmed|0 |1
Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot gnu.org
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(for cmp (lt ge le gt )
bop (bit_and bit_and bit_ior bit_ior)
rcmp (ne eq eq ne )
(simplify
(cmp (bop@2 @0 @1) @0)
(if (tree_expr_nonnegative_p (@0)
&& (bop == BIT_AND
|| tree_expr_nonnegative_p (@1)))
(rcmp @2 @0))))
I have not looked into what is needed for the IOR case for
!tree_expr_nonnegative_p (@1) yet but I suspect it is similar to what I did for
PR 101590.
Anyways mine.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-11-04 21:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-26 2:48 [Bug tree-optimization/112093] New: (X & Y) < X (unsigned) and (X & Y) != X should produce the same code pinskia at gcc dot gnu.org
2023-10-26 2:48 ` [Bug tree-optimization/112093] " pinskia at gcc dot gnu.org
2023-10-26 2:52 ` pinskia at gcc dot gnu.org
2023-11-04 21:10 ` 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).