[Bug middle-end/118879] Missed optimisation: std::in_range simpler size check
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Feb 14 19:04:00 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118879
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot gnu.org
Status|NEW |ASSIGNED
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #2)
> ```
> int f0(long long v)
> {
> unsigned long long t = v;
> t += 0x80'00'00'00ull;
> if (t <= 0xff'ff'ff'ff)
> return v;
> return 0;
> }
> ```
So something like:
```
(simplify
(le (plus @0 INTEGER_CST@2) INTEGER_CST@3))
(if (exact_log2 (@2) != -1 && @3 == mask(exact_log2 (@2)+1))
(with {
tree otype = TREE_TYPE (@0);
tree inner_type = signed_int_type (exact_log2 (@2)+1);
}
(eq (convert:otype (convert:itype @0)) @0))
```
ISo mine.
More information about the Gcc-bugs
mailing list