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
This commit is contained in:
Zdenek Dvorak 2006-02-23 22:03:05 +01:00 committed by Zdenek Dvorak
parent 65acccdd22
commit e755fcf517
4 changed files with 46 additions and 11 deletions

View File

@ -1,3 +1,15 @@
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.

View File

@ -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);

View File

@ -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);

View File

@ -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,