public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/112383] New: `a&=CST; (a&b) != a` and `((~b) & a) & CST != 0`
@ 2023-11-04 21:43 pinskia at gcc dot gnu.org
2023-11-09 3:28 ` [Bug middle-end/112383] " pinskia at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-04 21:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112383
Bug ID: 112383
Summary: `a&=CST; (a&b) != a` and `((~b) & a) & CST != 0`
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: enhancement
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Take:
```
int f1(unsigned a, unsigned b)
{
a &= 0x11;
return (a&b) != a;
}
int f2(unsigned a, unsigned b)
{
int d = 0x11;
int e = (~b) & a;
return (e&d) != 0;
}
```
These 2 should produce the same code.
Likewise for:
```
int fn1(unsigned a, unsigned b, unsigned c)
{
a &= c;
return (a&b) != a;
}
int fn2(unsigned a, unsigned b, unsigned c)
{
int d = c;
int e = (~b) & a;
return (e&d) != 0;
}
```
Note clang (LLVM) only produces the same code for f1/f2 pair, it misses the
Canonicalization for fn1/fn2 too.
Note for gimple f1/fn1 is simplier and most likely should be canonical.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug middle-end/112383] `a&=CST; (a&b) != a` and `((~b) & a) & CST != 0`
2023-11-04 21:43 [Bug middle-end/112383] New: `a&=CST; (a&b) != a` and `((~b) & a) & CST != 0` pinskia at gcc dot gnu.org
@ 2023-11-09 3:28 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-09 3:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112383
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=112382
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note the difference from PR 112382 is that PR 112382 is about a power of 2
while this is not any mask. I almost missed that even though I filed both.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-11-09 3:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-04 21:43 [Bug middle-end/112383] New: `a&=CST; (a&b) != a` and `((~b) & a) & CST != 0` pinskia at gcc dot gnu.org
2023-11-09 3:28 ` [Bug middle-end/112383] " 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).