From: Eric Botcazou Date: Tue, 25 Jul 2017 14:47:16 +0000 (+0000) Subject: gimple.c (gimple_assign_set_rhs_with_ops): Do not ask gsi_replace to update EH info... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a8697b270e4cf3a34dbf23c16952b070b7d73c09;p=gcc.git gimple.c (gimple_assign_set_rhs_with_ops): Do not ask gsi_replace to update EH info here. * gimple.c (gimple_assign_set_rhs_with_ops): Do not ask gsi_replace to update EH info here. ada/ * checks.adb (Apply_Divide_Checks): Ensure that operands are not evaluated twice. From-SVN: r250525 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 34bbe013441..cb7b47d9419 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2017-07-25 Eric Botcazou + + * gimple.c (gimple_assign_set_rhs_with_ops): Do not ask gsi_replace + to update EH info here. + 2017-07-25 Alexander Monakov * match.pd ((X * CST1) * CST2): Simplify to X * (CST1 * CST2). diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 5d6939c7aae..3daed1e1f35 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2017-07-25 Javier Miranda + + * checks.adb (Apply_Divide_Checks): Ensure that operands are not + evaluated twice. + 2017-07-19 Jakub Jelinek * gcc-interface/ada-tree.h (TYPE_OBJECT_RECORD_TYPE, diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb index 6162a0e38c0..a6670fa7697 100644 --- a/gcc/ada/checks.adb +++ b/gcc/ada/checks.adb @@ -1818,6 +1818,13 @@ package body Checks is and then ((not LOK) or else (Llo = LLB)) then + -- Ensure that expressions are not evaluated twice (once + -- for their runtime checks and once for their regular + -- computation). + + Force_Evaluation (Left, Mode => Strict); + Force_Evaluation (Right, Mode => Strict); + Insert_Action (N, Make_Raise_Constraint_Error (Loc, Condition => diff --git a/gcc/gimple.c b/gcc/gimple.c index 488f8c82b82..479f90c54c9 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -1613,7 +1613,7 @@ gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *gsi, enum tree_code code, gimple *new_stmt = gimple_alloc (gimple_code (stmt), new_rhs_ops + 1); memcpy (new_stmt, stmt, gimple_size (gimple_code (stmt))); gimple_init_singleton (new_stmt); - gsi_replace (gsi, new_stmt, true); + gsi_replace (gsi, new_stmt, false); stmt = new_stmt; /* The LHS needs to be reset as this also changes the SSA name diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6c25221694f..6b0336c6270 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2017-07-25 Eric Botcazou + + * gnat.dg/opt66.adb: New test. + 2017-07-25 Alexander Monakov * gcc.dg/tree-ssa/assoc-2.c: Enhance. diff --git a/gcc/testsuite/gnat.dg/opt66.adb b/gcc/testsuite/gnat.dg/opt66.adb new file mode 100644 index 00000000000..94a1790737c --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt66.adb @@ -0,0 +1,13 @@ +-- { dg-do compile } +-- { dg-options "-O" } + +procedure Opt66 (I : Integer) is + E : exception; +begin + if I = 0 then + raise E; + end if; + Opt66 (I - I / abs (I)); +exception + when others => null; +end;