]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/113693 - LC SSA and region VN
authorRichard Biener <rguenther@suse.de>
Thu, 1 Feb 2024 08:18:47 +0000 (09:18 +0100)
committerRichard Biener <rguenther@suse.de>
Thu, 1 Feb 2024 10:12:47 +0000 (11:12 +0100)
The following fixes LC SSA preserving with region VN which was broken
when availability checking was enhanced to treat not visited value
numbers as available.  The following makes sure to honor availability
data we put in place for LC SSA preserving instead.

PR tree-optimization/113693
* tree-ssa-sccvn.cc (rpo_elim::eliminate_avail): Honor avail
data when available.

* gcc.dg/pr113693.c: New testcase.

gcc/testsuite/gcc.dg/pr113693.c [new file with mode: 0644]
gcc/tree-ssa-sccvn.cc

diff --git a/gcc/testsuite/gcc.dg/pr113693.c b/gcc/testsuite/gcc.dg/pr113693.c
new file mode 100644 (file)
index 0000000..a6f5519
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do compile { target bitint } } */
+/* { dg-options "-O2 -fdbg-cnt=vect_loop:1" } */
+
+_BitInt(837) g, h;
+
+void
+fn1(void)
+{
+  for (; g; g++)
+    for (; h; h++)
+      ;
+}
+/* { dg-message "dbgcnt" "" { target *-*-* } 0 } */
index 9bed9b3cc69ce412f3b2ee027a7f8e63d8829c4e..bbcf86588f9fea0c4d70ab6e0bc8139ee5dbe00e 100644 (file)
@@ -7723,12 +7723,15 @@ rpo_elim::eliminate_avail (basic_block bb, tree op)
       if (SSA_NAME_IS_DEFAULT_DEF (valnum))
        return valnum;
       vn_ssa_aux_t valnum_info = VN_INFO (valnum);
-      /* See above.  */
-      if (!valnum_info->visited)
-       return valnum;
       vn_avail *av = valnum_info->avail;
       if (!av)
-       return NULL_TREE;
+       {
+         /* See above.  But when there's availability info prefer
+            what we recorded there for example to preserve LC SSA.  */
+         if (!valnum_info->visited)
+           return valnum;
+         return NULL_TREE;
+       }
       if (av->location == bb->index)
        /* On tramp3d 90% of the cases are here.  */
        return ssa_name (av->leader);