summaryrefslogtreecommitdiffstats
path: root/gcc/ifcvt.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ifcvt.c')
-rw-r--r--gcc/ifcvt.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c
index 4a13ba2a45b..8aba0d50efc 100644
--- a/gcc/ifcvt.c
+++ b/gcc/ifcvt.c
@@ -1965,6 +1965,25 @@ noce_process_if_block (struct ce_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_move (&if_info))
goto success;
if (noce_try_store_flag (&if_info))
OpenPOWER on IntegriCloud