Do not call range_of_ssa_name_with_loop_info with the loop tree root.
authorAldy Hernandez <aldyh@redhat.com>
Tue, 13 Oct 2020 07:05:23 +0000 (03:05 -0400)
committerAldy Hernandez <aldyh@redhat.com>
Wed, 14 Oct 2020 14:57:37 +0000 (10:57 -0400)
gcc/ChangeLog:

PR tree-optimization/97396
* gimple-range.cc (gimple_ranger::range_of_phi): Do not call
range_of_ssa_name_with_loop_info with the loop tree root.

gcc/testsuite/ChangeLog:

* gcc.dg/pr97396.c: New test.

gcc/gimple-range.cc
gcc/testsuite/gcc.dg/pr97396.c [new file with mode: 0644]

index 2ca86ed0e4c7153ca274d3b4f26ea53be30f96d5..999d631c5ee97d9fe1b51363f8cad1551c35c757 100644 (file)
@@ -490,7 +490,7 @@ gimple_ranger::range_of_phi (irange &r, gphi *phi)
     {
       value_range loop_range;
       class loop *l = loop_containing_stmt (phi);
-      if (l)
+      if (l && loop_outer (l))
         {
          range_of_ssa_name_with_loop_info (loop_range, phi_def, l, phi);
          if (!loop_range.varying_p ())
diff --git a/gcc/testsuite/gcc.dg/pr97396.c b/gcc/testsuite/gcc.dg/pr97396.c
new file mode 100644 (file)
index 0000000..d992c11
--- /dev/null
@@ -0,0 +1,23 @@
+// { dg-do compile }
+// { dg-options "-O1 -ftree-vrp" }
+// { dg-additional-options "-m32" { target { i?86-*-* x86_64-*-* } } }
+
+unsigned int
+po (char *os, unsigned int al)
+{
+  for (;;)
+    {
+      int qx = 0;
+
+      while (al < 1)
+        {
+          char *cw;
+
+          cw = os + qx;
+          if (cw)
+            return al + qx;
+
+          qx += sizeof *cw;
+        }
+    }
+}