re PR rtl-optimization/81424 (internal error on GPRbuild with -O2)
authorEric Botcazou <ebotcazou@adacore.com>
Sun, 16 Jul 2017 22:03:54 +0000 (22:03 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Sun, 16 Jul 2017 22:03:54 +0000 (22:03 +0000)
PR rtl-optimization/81424
* optabs.c (prepare_cmp_insn): Use copy_to_reg instead of force_reg
to remove potential trapping from operands if -fnon-call-exceptions.

From-SVN: r250246

gcc/ChangeLog
gcc/optabs.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/opt65.adb [new file with mode: 0644]

index 31979ed91b398022fca3fe4922eb639c1666d6f3..240ff4009d33b13d84ce02b66ee1831ff5db2a6c 100644 (file)
@@ -1,3 +1,9 @@
+2017-07-16  Eric Botcazou  <ebotcazou@adacore.com>
+
+       PR rtl-optimization/81424
+       * optabs.c (prepare_cmp_insn): Use copy_to_reg instead of force_reg
+       to remove potential trapping from operands if -fnon-call-exceptions.
+
 2017-07-16  Jan Hubicka  <hubicka@ucw.cz>
 
        * tree-ssa-loop-manip.c (tree_transform_and_unroll_loop): Use
index 39051326c7a13e0e31a21e581ac2e74571a39077..9258e5f888bfbecd4e3430eca0f31e072be1a64b 100644 (file)
@@ -3846,9 +3846,9 @@ prepare_cmp_insn (rtx x, rtx y, enum rtx_code comparison, rtx size,
   if (cfun->can_throw_non_call_exceptions)
     {
       if (may_trap_p (x))
-       x = force_reg (mode, x);
+       x = copy_to_reg (x);
       if (may_trap_p (y))
-       y = force_reg (mode, y);
+       y = copy_to_reg (y);
     }
 
   if (GET_MODE_CLASS (mode) == MODE_CC)
index 3ede9d83653e2e54ceb89b94cd3fb80d677a4379..872d24e010999fd0b82ebb1eb08c31c41c42b654 100644 (file)
@@ -1,3 +1,7 @@
+2017-07-16  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/opt65.adb: New test.
+
 2017-07-16  Jan Hubicka  <hubicka@ucw.cz>
 
        * gcc.dg/predict-8.c: Update.
diff --git a/gcc/testsuite/gnat.dg/opt65.adb b/gcc/testsuite/gnat.dg/opt65.adb
new file mode 100644 (file)
index 0000000..7b429b6
--- /dev/null
@@ -0,0 +1,30 @@
+-- { dg-do run }
+-- { dg-options "-O2" }
+
+with Ada.Command_Line; use Ada.Command_Line;
+
+procedure Opt65 is
+
+   procedure Check_Version_And_Help (Version_String : String) is
+      Help_Switch_Present    : Boolean := False;
+      Next_Arg               : Natural := 1;
+   begin
+      while Next_Arg <= Argument_Count loop
+         declare
+            Next_Argv : constant String := Argument (Next_Arg);
+         begin
+            if Next_Argv = "--help" then
+               Help_Switch_Present := True;
+            end if;
+            Next_Arg := Next_Arg + 1;
+         end;
+      end loop;
+
+      if Help_Switch_Present then
+         raise Program_Error;
+      end if;
+   end;
+
+begin
+   Check_Version_And_Help ("version");
+end;