public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/110068] New: missing min detection
@ 2023-06-01 3:30 pinskia at gcc dot gnu.org
2023-06-01 3:49 ` [Bug tree-optimization/110068] " pinskia at gcc dot gnu.org
2023-09-10 6:58 ` pinskia at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-01 3:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110068
Bug ID: 110068
Summary: missing min detection
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:
```
#define min1(x,y) ((x) < (y) ? (x) : (y))
#define min2(x,y) ((x) <= (y) ? (x) : (y))
static inline unsigned
min3(unsigned x, unsigned y)
{
return min1(x, y);
}
static inline unsigned
min4(unsigned x, unsigned y)
{
return min3(x, y);
}
unsigned
f1 (unsigned x)
{
return min1(x, 1U<<(sizeof(x)*8-1));
}
unsigned
f2 (unsigned x)
{
return min2(x, 1U<<(sizeof(x)*8-1));
}
unsigned
f3 (unsigned x)
{
return min3(x, 1U<<(sizeof(x)*8-1));
}
unsigned
f4 (unsigned x)
{
return min4(x, 1U<<(sizeof(x)*8-1));
}
```
f1,f2,f3, and f4 should all produce MIN_EXPRs but currently f1 does not.
I would have thought r11-1504-g2e0f4a18bc978 fixed this case but it does not.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/110068] missing min detection
2023-06-01 3:30 [Bug tree-optimization/110068] New: missing min detection pinskia at gcc dot gnu.org
@ 2023-06-01 3:49 ` pinskia at gcc dot gnu.org
2023-09-10 6:58 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-01 3:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110068
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
here is another one:
```
unsigned
f5 (unsigned x)
{
bool t = x >= 1U<<(sizeof(x)*8-1);
if (!t)
;
else
x = 1U<<(sizeof(x)*8-1);
return x;
}
```
this time LLVM does not detect it either.
easy way to see that out is by using riscv and -march=rv32gc_zba_zbb_zbc_zbs.
You should get for all 5 functions:
li a5,-2147483648
minu a0,a0,a5
ret
Or:
lui a1, 524288
minu a0, a0, a1
ret
Both are execute the same in the end.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/110068] missing min detection
2023-06-01 3:30 [Bug tree-optimization/110068] New: missing min detection pinskia at gcc dot gnu.org
2023-06-01 3:49 ` [Bug tree-optimization/110068] " pinskia at gcc dot gnu.org
@ 2023-09-10 6:58 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-10 6:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110068
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot gnu.org
Last reconfirmed| |2023-09-10
Ever confirmed|0 |1
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Mine.
I think I know how to fix this ...
minmax_from_comparison needs to pass the sign of what the exp0/exp1 are being
compared in.
Note I think we have other issues too ...
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-09-10 6:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-01 3:30 [Bug tree-optimization/110068] New: missing min detection pinskia at gcc dot gnu.org
2023-06-01 3:49 ` [Bug tree-optimization/110068] " pinskia at gcc dot gnu.org
2023-09-10 6:58 ` 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).