gimple.c (gimple_assign_set_rhs_with_ops): Do not ask gsi_replace to update EH info...
authorEric Botcazou <ebotcazou@gcc.gnu.org>
Tue, 25 Jul 2017 14:47:16 +0000 (14:47 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Tue, 25 Jul 2017 14:47:16 +0000 (14:47 +0000)
* 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

gcc/ChangeLog
gcc/ada/ChangeLog
gcc/ada/checks.adb
gcc/gimple.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/opt66.adb [new file with mode: 0644]

index 34bbe013441fcfa8b0dcc47fcf510cf304866e00..cb7b47d9419a263e9000df400b34da446ae2ca23 100644 (file)
@@ -1,3 +1,8 @@
+2017-07-25  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gimple.c (gimple_assign_set_rhs_with_ops): Do not ask gsi_replace
+       to update EH info here.
+
 2017-07-25  Alexander Monakov  <amonakov@ispras.ru>
 
        * match.pd ((X * CST1) * CST2): Simplify to X * (CST1 * CST2).
index 5d6939c7aae23f50637262ffb4101ce946eb2f9d..3daed1e1f35612ac5bb90360ee1fcb71df6cbcc2 100644 (file)
@@ -1,3 +1,8 @@
+2017-07-25  Javier Miranda  <miranda@adacore.com>
+
+       * checks.adb (Apply_Divide_Checks): Ensure that operands are not
+       evaluated twice. 
+
 2017-07-19  Jakub Jelinek  <jakub@redhat.com>
 
        * gcc-interface/ada-tree.h (TYPE_OBJECT_RECORD_TYPE,
index 6162a0e38c0462b5b9632f5b73f8382ddcecaf81..a6670fa7697d201dfcaaf90a4c3e391fe63f0dda 100644 (file)
@@ -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 =>
index 488f8c82b82e4b7266d3bfc97e74250fd65d0ed9..479f90c54c97b99440425841a8d270faafbb1fec 100644 (file)
@@ -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
index 6c25221694fdfb8b63febdaa43889a94afce41cf..6b0336c6270d30b04efe0f9fb770c97113ec98d4 100644 (file)
@@ -1,3 +1,7 @@
+2017-07-25 Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/opt66.adb: New test.
+
 2017-07-25  Alexander Monakov  <amonakov@ispras.ru>
 
        * 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 (file)
index 0000000..94a1790
--- /dev/null
@@ -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;