public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/114212] New: `MIN<uns, CST> / CST` -> `uns >= CST`
@ 2024-03-02 22:32 pinskia at gcc dot gnu.org
2024-03-02 22:34 ` [Bug tree-optimization/114212] " pinskia at gcc dot gnu.org
2024-03-03 5:56 ` pinskia at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-02 22:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114212
Bug ID: 114212
Summary: `MIN<uns, CST> / CST` -> `uns >= CST`
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:
```
unsigned f(unsigned a)
{
a = a >= 64 ? 64 : a;
return a/64; // a >= 64
}
```
This can be simplified to just `a >= 64` as if `a >= 64`, then `MIN<a,64>`
would be 64 and `64/64` is 1. Note this is actually true for all non-negative a
rather than just unsigned types.
For FP types, this can't be done as we won't just get 0,1 for the division but
the range [0.,1.].
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/114212] `MIN<uns, CST> / CST` -> `uns >= CST`
2024-03-02 22:32 [Bug tree-optimization/114212] New: `MIN<uns, CST> / CST` -> `uns >= CST` pinskia at gcc dot gnu.org
@ 2024-03-02 22:34 ` pinskia at gcc dot gnu.org
2024-03-03 5:56 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-02 22:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114212
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note I noticed this when looking at
https://github.com/llvm/llvm-project/issues/83676 but that is totally unrelated
since that is for mlir rather than LLVM's IR.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/114212] `MIN<uns, CST> / CST` -> `uns >= CST`
2024-03-02 22:32 [Bug tree-optimization/114212] New: `MIN<uns, CST> / CST` -> `uns >= CST` pinskia at gcc dot gnu.org
2024-03-02 22:34 ` [Bug tree-optimization/114212] " pinskia at gcc dot gnu.org
@ 2024-03-03 5:56 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-03 5:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114212
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
For mod, it is
`MIN<a,64> % 64` -> `a >= 64 ? 0 : a`
`(a >= 64 ? 64 : a) % 64` -> `a >= 64 ? (64 % 64) : (a % 64)` -> `a >= 64 ? 0 :
a` as a will be `a < 64` in the false case.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-03-03 5:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-02 22:32 [Bug tree-optimization/114212] New: `MIN<uns, CST> / CST` -> `uns >= CST` pinskia at gcc dot gnu.org
2024-03-02 22:34 ` [Bug tree-optimization/114212] " pinskia at gcc dot gnu.org
2024-03-03 5:56 ` 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).