[Bug tree-optimization/126751] New: (int)(((unsigned)a) + CST) should be simplified into a + CST if a+CST is known not to overflow in int
"pinskia at gcc dot gnu.org via Gcc-bugs" <[email protected]>
| Newsgroups | gmane.comp.gcc.bugs |
|---|---|
| Message-ID | <[email protected]/bugzilla/> |
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126751
Bug ID: 126751
Summary: (int)(((unsigned)a) + CST) should be simplified into a
+ CST if a+CST is known not to overflow in int
Product: gcc
Version: 17.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
Blocks: 126710
Target Milestone: ---
Noticed for PR 126710 but I thought it would be a good idea to split out:
```
int f(unsigned t)
{
int a = __builtin_clzg(t,32); // range is [0,32]
unsigned b = a;
b -= 10; // [-10, 22] no overflow in signed integer
a = b;
return a;
}
```
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126710
[Bug 126710] missed ifcvt optimization with clz