diff options
author | Zdenek Dvorak <dvorakz@suse.cz> | 2006-02-23 22:03:05 +0100 |
---|---|---|
committer | Zdenek Dvorak <rakdver@gcc.gnu.org> | 2006-02-23 21:03:05 +0000 |
commit | e755fcf517ba5a4f5e90737ec3290bbbc6ab1bba (patch) | |
tree | 0279569a12cde36a792d11397042f36e68a2ff7a /gcc | |
parent | 65acccdd22e3fc50f4272bc274e10e96dbbcd527 (diff) | |
download | gcc-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')
-rw-r--r-- | gcc/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/loop-invariant.c | 4 | ||||
-rw-r--r-- | gcc/rtl.h | 1 | ||||
-rw-r--r-- | gcc/rtlanal.c | 40 |
4 files changed, 46 insertions, 11 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9b05db88..4400f9a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,17 @@ 2006-02-23 Zdenek Dvorak <dvorakz@suse.cz> + 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. + +2006-02-23 Zdenek Dvorak <dvorakz@suse.cz> + * emit-rtl.c (immed_double_const): Cleanup. 2006-02-23 Daniel Berlin <dberlin@dberlin.org> diff --git a/gcc/loop-invariant.c b/gcc/loop-invariant.c index 3f8f6e3..553e9fe 100644 --- a/gcc/loop-invariant.c +++ b/gcc/loop-invariant.c @@ -479,7 +479,7 @@ find_identical_invariants (htab_t eq, struct invariant *inv) if (dump_file && inv->eqto != inv->invno) fprintf (dump_file, - "Invariant %d is equivalent to invariant %d.\n ", + "Invariant %d is equivalent to invariant %d.\n", inv->invno, inv->eqto); } @@ -775,7 +775,7 @@ find_invariant_insn (rtx insn, bool always_reached, bool always_executed) return; /* We cannot make trapping insn executed, unless it was executed before. */ - if (may_trap_p (PATTERN (insn)) && !always_reached) + if (may_trap_after_code_motion_p (PATTERN (insn)) && !always_reached) return; depends_on = BITMAP_ALLOC (NULL); @@ -1716,6 +1716,7 @@ extern int side_effects_p (rtx); extern int volatile_refs_p (rtx); extern int volatile_insn_p (rtx); extern int may_trap_p (rtx); +extern int may_trap_after_code_motion_p (rtx); extern int may_trap_or_fault_p (rtx); extern int inequality_comparisons_p (rtx); extern rtx replace_rtx (rtx, rtx, rtx); 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, |