diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2014-05-20 17:01:35 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2014-05-20 17:01:35 +0000 |
commit | 7eab31edf283c355051f1f58bc79ea13a0bdb3fd (patch) | |
tree | ea01704fc2a9e703217c6f711a0256643c25e1aa /gcc | |
parent | 467fc67c47287a490d649ffe03ce8ae432c27a71 (diff) | |
download | gcc-7eab31edf283c355051f1f58bc79ea13a0bdb3fd.zip gcc-7eab31edf283c355051f1f58bc79ea13a0bdb3fd.tar.gz gcc-7eab31edf283c355051f1f58bc79ea13a0bdb3fd.tar.bz2 |
tree-ssa-dom.c (hashable_expr_equal_p): Also compare the EH region of calls to pure functions that can throw an exception.
* tree-ssa-dom.c (hashable_expr_equal_p) <EXPR_CALL>: Also compare the
EH region of calls to pure functions that can throw an exception.
* tree-ssa-sccvn.c (vn_reference_eq): Remove duplicated test.
(copy_reference_ops_from_call): Also copy the EH region of the call if
it can throw an exception.
From-SVN: r210649
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/opt35.adb | 25 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/opt35_pkg.adb | 11 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/opt35_pkg.ads | 9 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/opt36.adb | 23 | ||||
-rw-r--r-- | gcc/tree-ssa-dom.c | 8 | ||||
-rw-r--r-- | gcc/tree-ssa-sccvn.c | 8 |
8 files changed, 94 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6f2db11..2ee681a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2014-05-20 Eric Botcazou <ebotcazou@adacore.com> + + * tree-ssa-dom.c (hashable_expr_equal_p) <EXPR_CALL>: Also compare the + EH region of calls to pure functions that can throw an exception. + * tree-ssa-sccvn.c (vn_reference_eq): Remove duplicated test. + (copy_reference_ops_from_call): Also copy the EH region of the call if + it can throw an exception. + 2014-05-20 Bill Schmidt <wschmidt@linux.vnet.ibm.com> * simplify-rtx.c (simplify_binary_operation_1): Optimize case of diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index be9a7de..cdb3d87 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2014-05-20 Eric Botcazou <ebotcazou@adacore.com> + + * gnat.dg/opt35.adb: New test. + * gnat.dg/opt36.adb: Likewise. + * gnat.dg/opt35_pkg.ad[sb]: New helper. + 2014-05-20 Paolo Carlini <paolo.carlini@oracle.com> PR c++/60373 diff --git a/gcc/testsuite/gnat.dg/opt35.adb b/gcc/testsuite/gnat.dg/opt35.adb new file mode 100644 index 0000000..b0defe0 --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt35.adb @@ -0,0 +1,25 @@ +-- { dg-do run } +-- { dg-options "-O" } + +with Opt35_Pkg; use Opt35_Pkg; + +procedure Opt35 is + I : Integer := -1; + N : Natural := 0; +begin + begin + I := F(0); + exception + when E => N := N + 1; + end; + + begin + I := I + F(0); + exception + when E => N := N + 1; + end; + + if N /= 2 or I = 0 then + raise Program_Error; + end if; +end; diff --git a/gcc/testsuite/gnat.dg/opt35_pkg.adb b/gcc/testsuite/gnat.dg/opt35_pkg.adb new file mode 100644 index 0000000..8e868c4 --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt35_pkg.adb @@ -0,0 +1,11 @@ +package body Opt35_Pkg is + + function F (I : Integer) return Integer is + begin + if I = 0 then + raise E; + end if; + return -I; + end; + +end Opt35_Pkg; diff --git a/gcc/testsuite/gnat.dg/opt35_pkg.ads b/gcc/testsuite/gnat.dg/opt35_pkg.ads new file mode 100644 index 0000000..3fcd3f3 --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt35_pkg.ads @@ -0,0 +1,9 @@ +package Opt35_Pkg is + + pragma Pure; + + E : Exception; + + function F (I : Integer) return Integer; + +end Opt35_Pkg; diff --git a/gcc/testsuite/gnat.dg/opt36.adb b/gcc/testsuite/gnat.dg/opt36.adb new file mode 100644 index 0000000..137db76 --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt36.adb @@ -0,0 +1,23 @@ +-- { dg-do run } +-- { dg-options "-O2" } + +with Opt35_Pkg; use Opt35_Pkg; + +procedure Opt36 is + I : Integer := -1; + N : Natural := 0; +begin + loop + begin + I := I + 1; + I := I + F(0); + exception + when E => N := N + 1; + end; + exit when I = 1; + end loop; + + if N /= 2 or I = 0 then + raise Program_Error; + end if; +end; diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c index 5b5adca..c980dfd 100644 --- a/gcc/tree-ssa-dom.c +++ b/gcc/tree-ssa-dom.c @@ -522,6 +522,14 @@ hashable_expr_equal_p (const struct hashable_expr *expr0, expr1->ops.call.args[i], 0)) return false; + if (stmt_could_throw_p (expr0->ops.call.fn_from)) + { + int lp0 = lookup_stmt_eh_lp (expr0->ops.call.fn_from); + int lp1 = lookup_stmt_eh_lp (expr1->ops.call.fn_from); + if ((lp0 > 0 || lp1 > 0) && lp0 != lp1) + return false; + } + return true; } diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index b45dc14..77dcad9 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -663,9 +663,6 @@ vn_reference_eq (const_vn_reference_t const vr1, const_vn_reference_t const vr2) { unsigned i, j; - if (vr1->hashcode != vr2->hashcode) - return false; - /* Early out if this is not a hash collision. */ if (vr1->hashcode != vr2->hashcode) return false; @@ -1125,6 +1122,7 @@ copy_reference_ops_from_call (gimple call, vn_reference_op_s temp; unsigned i; tree lhs = gimple_call_lhs (call); + int lr; /* If 2 calls have a different non-ssa lhs, vdef value numbers should be different. By adding the lhs here in the vector, we ensure that the @@ -1139,12 +1137,14 @@ copy_reference_ops_from_call (gimple call, result->safe_push (temp); } - /* Copy the type, opcode, function being called and static chain. */ + /* Copy the type, opcode, function, static chain and EH region, if any. */ memset (&temp, 0, sizeof (temp)); temp.type = gimple_call_return_type (call); temp.opcode = CALL_EXPR; temp.op0 = gimple_call_fn (call); temp.op1 = gimple_call_chain (call); + if (stmt_could_throw_p (call) && (lr = lookup_stmt_eh_lp (call)) > 0) + temp.op2 = size_int (lr); temp.off = -1; result->safe_push (temp); |