This adds the second testcase which we now also handle eliminating
a redundant PHI node.

Tested on x86_64-unknown-linux-gu.

2022-01-03  Richard Biener  <rguent...@suse.de>

        PR tree-optimization/66502
        * gcc.dg/tree-ssa/ssa-fre-98.c: New testcase.
---
 gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-98.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-98.c

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-98.c 
b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-98.c
new file mode 100644
index 00000000000..3d286099b25
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-98.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-fre1-details" } */
+
+int foo (int a, int s, unsigned int k)
+{
+  int i = a, j = a;
+  do
+    {
+      i += s;
+      j += j;
+      j -= a;
+    }
+  while (k--);
+  return j+i;
+}
+
+/* We want the redundant PHI for j to disappear.  */
+/* { dg-final { scan-tree-dump "Replaced redundant PHI node defining j" "fre1" 
} } */
-- 
2.31.1

Reply via email to