public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/110982] New: (unsigned)(signed_char) != (unsigned)-1 is never changed back into signed_char != -1
@ 2023-08-11 3:25 pinskia at gcc dot gnu.org
2023-08-11 8:53 ` [Bug tree-optimization/110982] " pinskia at gcc dot gnu.org
2023-09-25 8:52 ` pinskia at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-11 3:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110982
Bug ID: 110982
Summary: (unsigned)(signed_char) != (unsigned)-1 is never
changed back into signed_char != -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: ---
While looking into a failure after improving VRP, I see we never translate
this:
```
bool f(signed char t)
{
unsigned int t1 = t;
return t1 != (unsigned int)-1;
}
```
into:
```
bool f0(signed char t)
{
return t != -1;
}
```
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/110982] (unsigned)(signed_char) != (unsigned)-1 is never changed back into signed_char != -1
2023-08-11 3:25 [Bug tree-optimization/110982] New: (unsigned)(signed_char) != (unsigned)-1 is never changed back into signed_char != -1 pinskia at gcc dot gnu.org
@ 2023-08-11 8:53 ` pinskia at gcc dot gnu.org
2023-09-25 8:52 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-11 8:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110982
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The basic issue is int_fits_type_p does not work the way folks think it works
for casting from signed to unsigned and then casting back ...
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/110982] (unsigned)(signed_char) != (unsigned)-1 is never changed back into signed_char != -1
2023-08-11 3:25 [Bug tree-optimization/110982] New: (unsigned)(signed_char) != (unsigned)-1 is never changed back into signed_char != -1 pinskia at gcc dot gnu.org
2023-08-11 8:53 ` [Bug tree-optimization/110982] " pinskia at gcc dot gnu.org
@ 2023-09-25 8:52 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-25 8:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110982
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Last reconfirmed| |2023-09-25
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Another case where int_fits_type_p use causes an missed optimization is:
```
unsigned f(int a)
{
unsigned t = a;
if (a == -1)
return t;
return 0;
}
```
This should be caught in phiopt2 but currently is not due to the
int_fits_type_p usage.
I noticed this in PR 110131 .
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-09-25 8:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-11 3:25 [Bug tree-optimization/110982] New: (unsigned)(signed_char) != (unsigned)-1 is never changed back into signed_char != -1 pinskia at gcc dot gnu.org
2023-08-11 8:53 ` [Bug tree-optimization/110982] " pinskia at gcc dot gnu.org
2023-09-25 8:52 ` 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).