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
This commit is contained in:
parent
467fc67c47
commit
7eab31edf2
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
|
@ -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;
|
|
@ -0,0 +1,9 @@
|
|||
package Opt35_Pkg is
|
||||
|
||||
pragma Pure;
|
||||
|
||||
E : Exception;
|
||||
|
||||
function F (I : Integer) return Integer;
|
||||
|
||||
end Opt35_Pkg;
|
|
@ -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;
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue