tree-optimization/113693 - LC SSA and region VN
Checks
Commit Message
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.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
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 | 13 +++++++++++++
gcc/tree-ssa-sccvn.cc | 11 +++++++----
2 files changed, 20 insertions(+), 4 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/pr113693.c
new file mode 100644
@@ -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 } */
@@ -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);