When bounds_of_var_in_loop was converted to range_from_loop_direction,
the final check returned FALSE when the beginning and end bounds were
the same... The new code was using wi::gt_p, when it should have been
wi::ge_p when checking for the fail condition.
PR tree-optimization/120560
gcc/
* vr-values.cc (range_from_loop_direction): Use wi::ge_p rather
than wi::gt_p.
gcc/testsuite/
* gcc.dg/pr120560.c: New.
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O3 -fno-tree-ccp -fdump-tree-evrp" } */
+int main() {
+ int a = -1, b = 2, c = 1;
+ if (a >= 0)
+ c = 0;
+ while (1) {
+ if (-b + c - 7 >= 0)
+ return 0;
+ b = b - 1000 - 2147482648;
+ }
+}
+/* { dg-final { scan-tree-dump "return 0" "evrp" } } */
r.set_varying (type);
else if (dir == EV_DIR_GROWS)
{
- if (wi::gt_p (begin.lower_bound (), end.upper_bound (), sign))
+ if (wi::ge_p (begin.lower_bound (), end.upper_bound (), sign))
r.set_varying (type);
else
r = int_range<1> (type, begin.lower_bound (), end.upper_bound ());
}
else
{
- if (wi::gt_p (end.lower_bound (), begin.upper_bound (), sign))
+ if (wi::ge_p (end.lower_bound (), begin.upper_bound (), sign))
r.set_varying (type);
else
r = int_range<1> (type, end.lower_bound (), begin.upper_bound ());