tree-ssa-sccvn.c (vn_nary_op_compute_hash): Also canonicalize comparison operand...
authorRichard Biener <rguenth@gcc.gnu.org>
Thu, 13 Aug 2015 07:52:06 +0000 (07:52 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 13 Aug 2015 07:52:06 +0000 (07:52 +0000)
2015-08-12  Richard Biener  <rguenther@suse.de>

* tree-ssa-sccvn.c (vn_nary_op_compute_hash): Also canonicalize
comparison operand order and commutative ternary op operand order.
(sccvn_dom_walker::cond_stack): New state to track temporary
expressions.
(sccvn_dom_walker::after_dom_children): Remove tempoary expressions
no longer valid.
(sccvn_dom_walker::record_cond): Add a single temporary conditional
expression.
(sccvn_dom_walker::record_conds): Add a temporary conditional
expressions and all related expressions also true/false.
(sccvn_dom_walker::before_dom_children): Record temporary
expressions based on the controlling condition of a single
predecessor.  When trying to simplify a conditional statement
lookup expressions we might have inserted earlier.

* testsuite/gcc.dg/tree-ssa/ssa-fre-47.c: New testcase.
* testsuite/gcc.dg/tree-ssa/ssa-fre-48.c: Likewise.
* testsuite/gcc.dg/tree-ssa/ssa-fre-49.c: Likewise.
* testsuite/g++.dg/tree-ssa/pr61034.C: Adjust.
* testsuite/gcc.dg/fold-compare-2.c: Likewise.
* testsuite/gcc.dg/pr50763.c: Likewise.
* testsuite/gcc.dg/predict-3.c: Likewise.
* testsuite/gcc.dg/tree-ssa/20030709-2.c: Likewise.
* testsuite/gcc.dg/tree-ssa/pr19831-3.c: Likewise.
* testsuite/gcc.dg/tree-ssa/pr20657.c: Likewise.
* testsuite/gcc.dg/tree-ssa/pr21001.c: Likewise.
* testsuite/gcc.dg/tree-ssa/pr37508.c: Likewise.
* testsuite/gcc.dg/tree-ssa/vrp04.c: Likewise.
* testsuite/gcc.dg/tree-ssa/vrp07.c: Likewise.
* testsuite/gcc.dg/tree-ssa/vrp09.c: Likewise.
* testsuite/gcc.dg/tree-ssa/vrp16.c: Likewise.
* testsuite/gcc.dg/tree-ssa/vrp20.c: Likewise.
* testsuite/gcc.dg/tree-ssa/vrp25.c: Likewise.
* testsuite/gcc.dg/tree-ssa/vrp87.c: Likewise.

From-SVN: r226852

gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-47.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-48.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-49.c [new file with mode: 0644]

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-47.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-47.c
new file mode 100644 (file)
index 0000000..feee8ce
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-fre1" } */
+
+int foo (int i)
+{
+  if (i)
+    {
+      if (i)
+       return 0;
+      else
+       return 1;
+    }
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump "return 0;" "fre1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-48.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-48.c
new file mode 100644 (file)
index 0000000..b3d6102
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-fre1-details" } */
+
+int foo (int i)
+{
+  if (i)
+    {
+      if (i)
+       return 1;
+      else
+       return 0;
+    }
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump "Removing unexecutable edge" "fre1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-49.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-49.c
new file mode 100644 (file)
index 0000000..d64fb25
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-fre1" } */
+
+int foo (int i, int j)
+{
+  if (i < j)
+    {
+      if (i <= j)
+       return j > i;
+      else
+       return 0;
+    }
+  return 1;
+}
+
+/* { dg-final { scan-tree-dump "return 1;" "fre1" } }  */