public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/101650] New: (len | N) == len is transformed to len & N != 0
@ 2021-07-27 19:55 pinskia at gcc dot gnu.org
2021-07-27 19:56 ` [Bug tree-optimization/101650] " pinskia at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-27 19:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101650
Bug ID: 101650
Summary: (len | N) == len is transformed to len & N != 0
Product: gcc
Version: 12.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: ---
While looking at PR 101590, I noticed this one.
#include <stddef.h>
const size_t N = 4;
bool foo(size_t len) {
size_t newlen = len | N;
return newlen == len;
}
(for cmp (NE EQ)
icmp (EQ NE)
(simplify
(cmp (bit_ior @0 INTEGER_CST@1) @0)
(icmp (bit_and @0 @1) ({ build_zero_cst (TREE_TYPE (@0)); })
)
)
This is already done for bit_and.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/101650] (len | N) == len is transformed to len & N != 0
2021-07-27 19:55 [Bug tree-optimization/101650] New: (len | N) == len is transformed to len & N != 0 pinskia at gcc dot gnu.org
@ 2021-07-27 19:56 ` pinskia at gcc dot gnu.org
2021-07-27 20:02 ` pinskia at gcc dot gnu.org
2023-08-23 1:22 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-27 19:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101650
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2021-07-27
Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot gnu.org
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=101590
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/101650] (len | N) == len is transformed to len & N != 0
2021-07-27 19:55 [Bug tree-optimization/101650] New: (len | N) == len is transformed to len & N != 0 pinskia at gcc dot gnu.org
2021-07-27 19:56 ` [Bug tree-optimization/101650] " pinskia at gcc dot gnu.org
@ 2021-07-27 20:02 ` pinskia at gcc dot gnu.org
2023-08-23 1:22 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-27 20:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101650
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 101591 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/101650] (len | N) == len is transformed to len & N != 0
2021-07-27 19:55 [Bug tree-optimization/101650] New: (len | N) == len is transformed to len & N != 0 pinskia at gcc dot gnu.org
2021-07-27 19:56 ` [Bug tree-optimization/101650] " pinskia at gcc dot gnu.org
2021-07-27 20:02 ` pinskia at gcc dot gnu.org
@ 2023-08-23 1:22 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-23 1:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101650
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So the pattern which we have currently matching (X | Y) == Y does this:
/* (X | Y) == Y becomes (X & ~Y) == 0. */
(simplify
(cmp:c (bit_ior:c @0 @1) @1)
(cmp (bit_and @0 (bit_not! @1)) { build_zero_cst (TREE_TYPE (@0)); }))
So adding:
/* (Y | CST) == Y becomes (Y & CST) != 0. */
(simplify
(cmp:c (bit_ior @1 INTEGER_CST@0) @1)
(icmp (bit_and @1 @0) { build_zero_cst (TREE_TYPE (@0)); }))
Is needed.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-08-23 1:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-27 19:55 [Bug tree-optimization/101650] New: (len | N) == len is transformed to len & N != 0 pinskia at gcc dot gnu.org
2021-07-27 19:56 ` [Bug tree-optimization/101650] " pinskia at gcc dot gnu.org
2021-07-27 20:02 ` pinskia at gcc dot gnu.org
2023-08-23 1:22 ` 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).