public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/110010] New: (a>>N) != (b>>N) is not optimized to (a^b) >= (1<<N)
@ 2023-05-28 0:31 pinskia at gcc dot gnu.org
2023-05-28 0:37 ` [Bug tree-optimization/110010] " pinskia at gcc dot gnu.org
2023-09-04 7:57 ` pinskia at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-28 0:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110010
Bug ID: 110010
Summary: (a>>N) != (b>>N) is not optimized to (a^b) >= (1<<N)
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:
```
#define N 5
unsigned f(unsigned a, unsigned b)
{
return (a>>N) != (b>>N);
}
```
This could be optimized down to just `return (a^b) <= (1<<N)`.
This shows up in the testsuite as a pr94718-5.c failure when you add the
following 2 match patterns:
(simplify
(negate (convert (lt @0 integer_zerop)))
(if (!TYPE_UNSIGNED (TREE_TYPE (@0)))
(with { tree type_unsigned = unsigned_type_for (TREE_TYPE (@0)); }
(if (types_match (type, TREE_TYPE (@0)) || types_match (type_unsigned,
type))
(convert (rshift @0
{ build_int_cst (integer_type_node,
element_precision (type) - 1); }))))))
(simplify
(convert (lt @0 integer_zerop))
(if (!TYPE_UNSIGNED (TREE_TYPE (@0)))
(with { tree type_unsigned = unsigned_type_for (TREE_TYPE (@0)); }
(if (types_match (type, TREE_TYPE (@0)) || types_match (type_unsigned,
type))
(convert (rshift (convert:type_unsigned @0)
{ build_int_cst (integer_type_node,
element_precision (type) - 1); }))))))
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/110010] (a>>N) != (b>>N) is not optimized to (a^b) >= (1<<N)
2023-05-28 0:31 [Bug tree-optimization/110010] New: (a>>N) != (b>>N) is not optimized to (a^b) >= (1<<N) pinskia at gcc dot gnu.org
@ 2023-05-28 0:37 ` pinskia at gcc dot gnu.org
2023-09-04 7:57 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-28 0:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110010
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/110010] (a>>N) != (b>>N) is not optimized to (a^b) >= (1<<N)
2023-05-28 0:31 [Bug tree-optimization/110010] New: (a>>N) != (b>>N) is not optimized to (a^b) >= (1<<N) pinskia at gcc dot gnu.org
2023-05-28 0:37 ` [Bug tree-optimization/110010] " pinskia at gcc dot gnu.org
@ 2023-09-04 7:57 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-04 7:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110010
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2023-09-04
Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Mine.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-09-04 7:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-28 0:31 [Bug tree-optimization/110010] New: (a>>N) != (b>>N) is not optimized to (a^b) >= (1<<N) pinskia at gcc dot gnu.org
2023-05-28 0:37 ` [Bug tree-optimization/110010] " pinskia at gcc dot gnu.org
2023-09-04 7: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).