]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Some ssa-names get incorrectly marked as always_current.
authorAndrew MacLeod <amacleod@redhat.com>
Thu, 7 Sep 2023 15:15:50 +0000 (11:15 -0400)
committerAndrew MacLeod <amacleod@redhat.com>
Thu, 7 Sep 2023 19:20:14 +0000 (15:20 -0400)
When range_of_stmt invokes prefill_name to evaluate unvisited dependencies
it should not mark already visited names as always_current.

PR tree-optimization/110875
gcc/
* gimple-range.cc (gimple_ranger::prefill_name): Only invoke
cache-prefilling routine when the ssa-name has no global value.

gcc/testsuite/
* gcc.dg/pr110875.c: New.

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

index 01173c58f02b424f8a131e1fc9fda17dcf1d70f9..13c3308d53791bd9bbe0b24831578c8fe612bd30 100644 (file)
@@ -351,10 +351,14 @@ gimple_ranger::prefill_name (vrange &r, tree name)
   if (!gimple_range_op_handler::supported_p (stmt) && !is_a<gphi *> (stmt))
     return;
 
-  bool current;
   // If this op has not been processed yet, then push it on the stack
-  if (!m_cache.get_global_range (r, name, current))
-    m_stmt_list.safe_push (name);
+  if (!m_cache.get_global_range (r, name))
+    {
+      bool current;
+      // Set the global cache value and mark as alway_current.
+      m_cache.get_global_range (r, name, current);
+      m_stmt_list.safe_push (name);
+    }
 }
 
 // This routine will seed the global cache with most of the dependencies of
diff --git a/gcc/testsuite/gcc.dg/pr110875.c b/gcc/testsuite/gcc.dg/pr110875.c
new file mode 100644 (file)
index 0000000..4d6ecbc
--- /dev/null
@@ -0,0 +1,34 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-vrp2" } */
+
+void foo(void);
+static int a, b;
+static int *c = &a, *d;
+static unsigned e;
+static short f;
+static unsigned g(unsigned char h, char i) { return h + i; }
+int main() {
+    d = &a;
+    int *j = d;
+    e = -27;
+    for (; e > 18; e = g(e, 6)) {
+        a = 0;
+        for (; a != -3; a--) {
+            if (0 != a ^ *j)
+                for (; b; b++) f = -f;
+            else if (*c) {
+                foo();
+                break;
+            }
+            if (!(((e) >= 235) && ((e) <= 4294967269))) {
+                __builtin_unreachable();
+            }
+            b = 0;
+        }
+    }
+}
+
+
+/* { dg-final { scan-tree-dump-not "foo" "vrp2" } } */
+
+