public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/114092] New: ADD_OVERFLOW<a, 0> with resulting type of `_Complex unsigned:1` should be reduced to just `(unsigned)(a) <= 1`
@ 2024-02-24 20:38 pinskia at gcc dot gnu.org
2024-02-24 20:44 ` [Bug tree-optimization/114092] " pinskia at gcc dot gnu.org
2024-02-24 20:57 ` jakub at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-24 20:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114092
Bug ID: 114092
Summary: ADD_OVERFLOW<a, 0> with resulting type of `_Complex
unsigned:1` should be reduced to just `(unsigned)(a)
<= 1`
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:
```
struct d
{
unsigned i:1;
};
_Bool f(int a, struct d b)
{
return __builtin_add_overflow_p(a, 0, b.i);
}
_Bool f1(int a, struct d b)
{
return a != 1 && a != 0;
}
```
These 2 functions should produce the same. Here `a+0` overflows an `unsigned:1`
if the value of a is not 0 or 1.
We could extend this to any smaller types too if we want.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/114092] ADD_OVERFLOW<a, 0> with resulting type of `_Complex unsigned:1` should be reduced to just `(unsigned)(a) <= 1`
2024-02-24 20:38 [Bug tree-optimization/114092] New: ADD_OVERFLOW<a, 0> with resulting type of `_Complex unsigned:1` should be reduced to just `(unsigned)(a) <= 1` pinskia at gcc dot gnu.org
@ 2024-02-24 20:44 ` pinskia at gcc dot gnu.org
2024-02-24 20:57 ` jakub at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-24 20:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114092
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I should note that LLVM (LLVM does not have __builtin_add_overflow_p) is able
to optimize:
```
_Bool f2(int a, struct d b, unsigned _BitInt(1) t)
{
return __builtin_add_overflow(a, 0, &t);
}
```
into f1.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/114092] ADD_OVERFLOW<a, 0> with resulting type of `_Complex unsigned:1` should be reduced to just `(unsigned)(a) <= 1`
2024-02-24 20:38 [Bug tree-optimization/114092] New: ADD_OVERFLOW<a, 0> with resulting type of `_Complex unsigned:1` should be reduced to just `(unsigned)(a) <= 1` pinskia at gcc dot gnu.org
2024-02-24 20:44 ` [Bug tree-optimization/114092] " pinskia at gcc dot gnu.org
@ 2024-02-24 20:57 ` jakub at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-02-24 20:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114092
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Guess all of .ADD_OVERFLOW (x, 0), .ADD_OVERFLOW (0, x) and .SUB_OVERFLOW (x,
0)
to REALPART_EXPR = (type) x and IMAGPART_EXPR to (type) x != x. Just need to
figure out for which types it is beneficial and for which it isn't.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-24 20:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-24 20:38 [Bug tree-optimization/114092] New: ADD_OVERFLOW<a, 0> with resulting type of `_Complex unsigned:1` should be reduced to just `(unsigned)(a) <= 1` pinskia at gcc dot gnu.org
2024-02-24 20:44 ` [Bug tree-optimization/114092] " pinskia at gcc dot gnu.org
2024-02-24 20:57 ` jakub 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).