]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR rtl-optimization/13400 (Compiled code crashes storing to read-only location)
authorRoger Sayle <roger@eyesopen.com>
Sun, 21 Dec 2003 16:08:06 +0000 (16:08 +0000)
committerRoger Sayle <sayle@gcc.gnu.org>
Sun, 21 Dec 2003 16:08:06 +0000 (16:08 +0000)
PR middle-end/13400
* ifcvt.c (noce_process_if_block): Disable unconditional write
optimizations if we could introduce a store to trapping memory
that wasn't present previously.

* gcc.c-torture/execute/20031215-1.c: New test case.

From-SVN: r74910

gcc/ChangeLog
gcc/ifcvt.c
gcc/testsuite/ChangeLog

index 502b6595999124eda3dd72bdefd9a375e5360062..f9e10903373cf1396282fb9512200403503f95f9 100644 (file)
@@ -1,3 +1,10 @@
+2003-12-21  Roger Sayle  <roger@eyesopen.com>
+
+       PR middle-end/13400
+       * ifcvt.c (noce_process_if_block): Disable unconditional write
+       optimizations if we could introduce a store to trapping memory
+       that wasn't present previously.
+
 2003-12-20  Roger Sayle  <roger@eyesopen.com>
 
        PR optimization/13031
index c3360043bd72c6f79555919ebe3b864b75861d15..cd936e7e77584be57f32145743192d0d5d3d57d0 100644 (file)
@@ -1871,6 +1871,25 @@ noce_process_if_block (ce_info)
       goto success;
     }
 
+  /* Disallow the "if (...) x = a;" form (with an implicit "else x = x;")
+     for most optimizations if writing to x may trap, i.e. its a memory
+     other than a static var or a stack slot.  */
+  if (! set_b
+      && GET_CODE (orig_x) == MEM
+      && ! MEM_NOTRAP_P (orig_x)
+      && rtx_addr_can_trap_p (XEXP (orig_x, 0)))
+    {
+      if (HAVE_conditional_move)
+       {
+         if (noce_try_cmove (&if_info))
+           goto success;
+         if (! HAVE_conditional_execution
+             && noce_try_cmove_arith (&if_info))
+           goto success;
+       }
+      return FALSE;
+    }
+
   if (noce_try_store_flag (&if_info))
     goto success;
   if (noce_try_minmax (&if_info))
index 8d775c8c3947bbdb04970f243a47e955356bc986..2b979bdfd0ac4f66bee76a6b27ab91f80ff07815 100644 (file)
@@ -1,3 +1,8 @@
+2003-12-21  Roger Sayle  <roger@eyesopen.com>
+
+       PR middle-end/13400
+       * gcc.c-torture/execute/20031215-1.c: New test case.
+
 2003-12-20  Roger Sayle  <roger@eyesopen.com>
 
        PR optimization/13031