From 4be182b923d4c72db0b6dcade8e617fbe95c22b6 Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Sat, 7 Jun 2014 11:59:18 +0000 Subject: [PATCH] * tree-ssa-tail-merge.c (same_succ_hash): Hash the static chain of a call statement, if any. (gimple_equal_p) : Compare the static chain of the call statements, if any. Tidy up. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@211342 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 7 +++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gnat.dg/opt38.adb | 9 +++++++++ gcc/testsuite/gnat.dg/opt38_pkg.adb | 33 +++++++++++++++++++++++++++++++++ gcc/testsuite/gnat.dg/opt38_pkg.ads | 5 +++++ gcc/tree-ssa-tail-merge.c | 21 +++++++++++++++------ 6 files changed, 74 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gnat.dg/opt38.adb create mode 100644 gcc/testsuite/gnat.dg/opt38_pkg.adb create mode 100644 gcc/testsuite/gnat.dg/opt38_pkg.ads diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1966add9a53..d7a35c3f6a3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2014-06-07 Eric Botcazou + + * tree-ssa-tail-merge.c (same_succ_hash): Hash the static chain of a + call statement, if any. + (gimple_equal_p) : Compare the static chain of the call + statements, if any. Tidy up. + 2014-06-06 Michael Meissner PR target/61431 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4e3967ecc41..a6913af74fd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-06-07 Eric Botcazou + + * gnat.dg/opt38.adb: New test. + * gnat.dg/opt38_pkg.ad[sb]: New helper. + 2014-06-07 Hans-Peter Nilsson PR target/18343 diff --git a/gcc/testsuite/gnat.dg/opt38.adb b/gcc/testsuite/gnat.dg/opt38.adb new file mode 100644 index 00000000000..143f4fade19 --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt38.adb @@ -0,0 +1,9 @@ +-- { dg-do run } +-- { dg-options "-O2 -gnatn" } + +with Opt38_Pkg; use Opt38_Pkg; + +procedure Opt38 is +begin + Test (-1); +end; diff --git a/gcc/testsuite/gnat.dg/opt38_pkg.adb b/gcc/testsuite/gnat.dg/opt38_pkg.adb new file mode 100644 index 00000000000..7cbbeeab328 --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt38_pkg.adb @@ -0,0 +1,33 @@ +package body Opt38_Pkg is + + procedure Proc (I : Integer); + pragma Inline (Proc); + + procedure Proc (I : Integer) is + + procedure Inner; + pragma No_Inline (Inner); + + procedure Inner is + begin + if I /= 110 then + raise Program_Error; + end if; + end; + + begin + if I > 0 then + Inner; + end if; + end; + + procedure Test (I : Integer) is + begin + if I > -1 then + Proc (I); + else + Proc (I + 111); + end if; + end; + +end Opt38_Pkg; diff --git a/gcc/testsuite/gnat.dg/opt38_pkg.ads b/gcc/testsuite/gnat.dg/opt38_pkg.ads new file mode 100644 index 00000000000..b6cb4e6bc72 --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt38_pkg.ads @@ -0,0 +1,5 @@ +package Opt38_Pkg is + + procedure Test (I : Integer); + +end Opt38_Pkg; diff --git a/gcc/tree-ssa-tail-merge.c b/gcc/tree-ssa-tail-merge.c index 20fbebf35d0..65b5a4e4420 100644 --- a/gcc/tree-ssa-tail-merge.c +++ b/gcc/tree-ssa-tail-merge.c @@ -481,7 +481,11 @@ same_succ_hash (const_same_succ e) hashval = iterative_hash_hashval_t ((hashval_t) gimple_call_internal_fn (stmt), hashval); else - hashval = iterative_hash_expr (gimple_call_fn (stmt), hashval); + { + hashval = iterative_hash_expr (gimple_call_fn (stmt), hashval); + if (gimple_call_chain (stmt)) + hashval = iterative_hash_expr (gimple_call_chain (stmt), hashval); + } for (i = 0; i < gimple_call_num_args (stmt); i++) { arg = gimple_call_arg (stmt, i); @@ -1121,18 +1125,23 @@ gimple_equal_p (same_succ same_succ, gimple s1, gimple s2) switch (gimple_code (s1)) { case GIMPLE_CALL: - if (gimple_call_num_args (s1) != gimple_call_num_args (s2)) - return false; if (!gimple_call_same_target_p (s1, s2)) return false; + t1 = gimple_call_chain (s1); + t2 = gimple_call_chain (s2); + if (!gimple_operand_equal_value_p (t1, t2)) + return false; + + if (gimple_call_num_args (s1) != gimple_call_num_args (s2)) + return false; + for (i = 0; i < gimple_call_num_args (s1); ++i) { t1 = gimple_call_arg (s1, i); t2 = gimple_call_arg (s2, i); - if (gimple_operand_equal_value_p (t1, t2)) - continue; - return false; + if (!gimple_operand_equal_value_p (t1, t2)) + return false; } lhs1 = gimple_get_lhs (s1); -- 2.11.4.GIT