https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126076
Bug ID: 126076
Summary: missing frange related optimization with bit_and for
the comparison where one of the sides is used twice
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Take:
```
// { dg-options "-O2 -fdump-tree-evrp -fno-thread-jumps" }
void use (double);
void link_error ();
void
foo (double x)
{
double y,z;
int t = x >= 0.5;
int t1 = x <= 1.3;
int t2 = x < 1.75;
if (t & t1)
{
y = __builtin_sin (x);
if (y < 0.45 || y > 0.97)
link_error ();
use (y);
}
if (t & t2)
{
z = __builtin_sin (x);
if (z < 0.45 || z > 1.05)
link_error ();
use (z);
}
}
```
This at `-O2 -fno-thread-jumps`, link_error should be optimized away. But
currently it is not.
This is reduced from gcc.dg/tree-ssa/range-sincos-2.c with -fno-trapping-math
used.