aboutsummaryrefslogtreecommitdiff
path: root/gcc/rtlanal.c
diff options
context:
space:
mode:
authorZdenek Dvorak <dvorakz@suse.cz>2006-02-23 22:03:05 +0100
committerZdenek Dvorak <rakdver@gcc.gnu.org>2006-02-23 21:03:05 +0000
commite755fcf517ba5a4f5e90737ec3290bbbc6ab1bba (patch)
tree0279569a12cde36a792d11397042f36e68a2ff7a /gcc/rtlanal.c
parent65acccdd22e3fc50f4272bc274e10e96dbbcd527 (diff)
downloadgcc-e755fcf517ba5a4f5e90737ec3290bbbc6ab1bba.zip
gcc-e755fcf517ba5a4f5e90737ec3290bbbc6ab1bba.tar.gz
gcc-e755fcf517ba5a4f5e90737ec3290bbbc6ab1bba.tar.bz2
re PR middle-end/26316 (loop-invariant miscompiles openmp.c)
PR rtl-optimization/26316 * rtlanal.c (enum may_trap_p_flags): New. (may_trap_p_1): Take flags instead of unaligned_mems argument. Ignore MEM_NOTRAP_P if flags & MTP_AFTER_MOVE. (may_trap_p, may_trap_or_fault_p): Pass flags to may_trap_p_1. (may_trap_after_code_motion_p): New function. * loop-invariant.c (find_identical_invariants): Fix dump formating. (find_invariant_insn): Use may_trap_after_code_motion_p. * rtl.h (may_trap_after_code_motion_p): Declare. From-SVN: r111397
Diffstat (limited to 'gcc/rtlanal.c')
-rw-r--r--gcc/rtlanal.c40
1 files changed, 31 insertions, 9 deletions
diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c
index 7c7731b..d8c9fb8 100644
--- a/gcc/rtlanal.c
+++ b/gcc/rtlanal.c
@@ -2033,16 +2033,25 @@ side_effects_p (rtx x)
return 0;
}
-/* Return nonzero if evaluating rtx X might cause a trap. UNALIGNED_MEMS
- controls whether nonzero is returned for unaligned memory accesses on
- strict alignment machines. */
+enum may_trap_p_flags
+{
+ MTP_UNALIGNED_MEMS = 1,
+ MTP_AFTER_MOVE = 2
+};
+/* Return nonzero if evaluating rtx X might cause a trap.
+ (FLAGS & MTP_UNALIGNED_MEMS) controls whether nonzero is returned for
+ unaligned memory accesses on strict alignment machines. If
+ (FLAGS & AFTER_MOVE) is true, returns nonzero even in case the expression
+ cannot trap at its current location, but it might become trapping if moved
+ elsewhere. */
static int
-may_trap_p_1 (rtx x, bool unaligned_mems)
+may_trap_p_1 (rtx x, unsigned flags)
{
int i;
enum rtx_code code;
const char *fmt;
+ bool unaligned_mems = (flags & MTP_UNALIGNED_MEMS) != 0;
if (x == 0)
return 0;
@@ -2072,7 +2081,11 @@ may_trap_p_1 (rtx x, bool unaligned_mems)
/* Memory ref can trap unless it's a static var or a stack slot. */
case MEM:
- if (MEM_NOTRAP_P (x)
+ if (/* MEM_NOTRAP_P only relates to the actual position of the memory
+ reference; moving it out of condition might cause its address
+ become invalid. */
+ !(flags & MTP_AFTER_MOVE)
+ && MEM_NOTRAP_P (x)
&& (!STRICT_ALIGNMENT || !unaligned_mems))
return 0;
return
@@ -2152,14 +2165,14 @@ may_trap_p_1 (rtx x, bool unaligned_mems)
{
if (fmt[i] == 'e')
{
- if (may_trap_p_1 (XEXP (x, i), unaligned_mems))
+ if (may_trap_p_1 (XEXP (x, i), flags))
return 1;
}
else if (fmt[i] == 'E')
{
int j;
for (j = 0; j < XVECLEN (x, i); j++)
- if (may_trap_p_1 (XVECEXP (x, i, j), unaligned_mems))
+ if (may_trap_p_1 (XVECEXP (x, i, j), flags))
return 1;
}
}
@@ -2171,7 +2184,16 @@ may_trap_p_1 (rtx x, bool unaligned_mems)
int
may_trap_p (rtx x)
{
- return may_trap_p_1 (x, false);
+ return may_trap_p_1 (x, 0);
+}
+
+/* Return nonzero if evaluating rtx X might cause a trap, when the expression
+ is moved from its current location by some optimization. */
+
+int
+may_trap_after_code_motion_p (rtx x)
+{
+ return may_trap_p_1 (x, MTP_AFTER_MOVE);
}
/* Same as above, but additionally return non-zero if evaluating rtx X might
@@ -2217,7 +2239,7 @@ may_trap_p (rtx x)
int
may_trap_or_fault_p (rtx x)
{
- return may_trap_p_1 (x, true);
+ return may_trap_p_1 (x, MTP_UNALIGNED_MEMS);
}
/* Return nonzero if X contains a comparison that is not either EQ or NE,