From 89711ff6cbe5455fb5f4b42038e072d764b30579 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Thu, 13 Aug 2015 07:52:06 +0000 Subject: [PATCH] tree-ssa-sccvn.c (vn_nary_op_compute_hash): Also canonicalize comparison operand order and commutative ternary op operand order. 2015-08-12 Richard Biener * 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 | 16 ++++++++++++++++ gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-48.c | 16 ++++++++++++++++ gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-49.c | 16 ++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-47.c create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-48.c create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-49.c 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 index 00000000000..feee8ceb707 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-47.c @@ -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 index 00000000000..b3d610204da --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-48.c @@ -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 index 00000000000..d64fb250920 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-49.c @@ -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" } } */ -- 2.30.2