[PATCH] Fix PR rtl-optimization/24257
Richard Guenther
rguenther@suse.de
Tue Jan 10 12:33:00 GMT 2006
This patch from Steven fixes PR24257.
Bootstrapped and tested on i686-pc-linux-gnu.
Ok for mainline and 4.1?
Thanks,
Richard.
2006-01-10 Steven Bosscher <steven.bosscher@gmail.com>
Richard Guenther <rguenther@suse.de>
PR rtl-optimization/24257
* gcse.c (find_moveable_store): Only consider a store movable
when the SET_SRC of the insn can be assigned to a register.
* gcc.dg/torture/pr24257.c: New testcase.
Index: gcse.c
===================================================================
--- gcse.c (revision 109509)
+++ gcse.c (working copy)
@@ -5647,6 +5647,14 @@ find_moveable_store (rtx insn, int *regs
if (find_reg_note (insn, REG_EH_REGION, NULL_RTX))
return;
+ /* Make sure that the SET_SRC of this store insns can be assigned to
+ a register, or we will fail later on in replace_store_insn, which
+ assumes that we can do this. But sometimes the target machine has
+ oddities like MEM read-modify-write instruction. See for example
+ PR24257. */
+ if (!can_assign_to_reg_p (SET_SRC (set)))
+ return;
+
ptr = ldst_entry (dest);
if (!ptr->pattern_regs)
ptr->pattern_regs = extract_mentioned_regs (dest);
/* { dg-do compile } */
/* { dg-options "-O -fgcse -fgcse-sm" } */
typedef struct A {
int buf, left;
} A;
static void flush(A *s, int n)
{
s->buf <<= n;
while (s->left < 32) {
s->buf <<= 8;
s->left += 8;
}
s->buf=0;
}
void oof(A *s, int n)
{
s->buf = n;
s->left = n;
flush(s, n);
}
More information about the Gcc-patches
mailing list