re PR target/21297 (buf[i+i]=0 stores buf[i] when -O2)
PR target/21297 * config/i386/i386.c (legitimize_address): When canonicalizing ASHIFT into MULT, multiply by 1 << shift_count instead of 1 << log2 (shift_count). * gcc.c-torture/execute/20050502-2.c: New test. From-SVN: r99156
This commit is contained in:
parent
f47c96aac5
commit
85b583d30a
@ -1,3 +1,10 @@
|
||||
2005-05-03 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR target/21297
|
||||
* config/i386/i386.c (legitimize_address): When canonicalizing
|
||||
ASHIFT into MULT, multiply by 1 << shift_count instead of
|
||||
1 << log2 (shift_count).
|
||||
|
||||
2005-05-03 Andrew MacLeod <amacleod@redhat.com>
|
||||
|
||||
* lambda-code.c (gcc_loop_to_lambda_loop,
|
||||
|
@ -5902,9 +5902,10 @@ legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED, enum machine_mode mode)
|
||||
/* Canonicalize shifts by 0, 1, 2, 3 into multiply */
|
||||
if (GET_CODE (x) == ASHIFT
|
||||
&& GET_CODE (XEXP (x, 1)) == CONST_INT
|
||||
&& (log = (unsigned) exact_log2 (INTVAL (XEXP (x, 1)))) < 4)
|
||||
&& (unsigned HOST_WIDE_INT) INTVAL (XEXP (x, 1)) < 4)
|
||||
{
|
||||
changed = 1;
|
||||
log = INTVAL (XEXP (x, 1));
|
||||
x = gen_rtx_MULT (Pmode, force_reg (Pmode, XEXP (x, 0)),
|
||||
GEN_INT (1 << log));
|
||||
}
|
||||
@ -5915,9 +5916,10 @@ legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED, enum machine_mode mode)
|
||||
|
||||
if (GET_CODE (XEXP (x, 0)) == ASHIFT
|
||||
&& GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT
|
||||
&& (log = (unsigned) exact_log2 (INTVAL (XEXP (XEXP (x, 0), 1)))) < 4)
|
||||
&& (unsigned HOST_WIDE_INT) INTVAL (XEXP (XEXP (x, 0), 1)) < 4)
|
||||
{
|
||||
changed = 1;
|
||||
log = INTVAL (XEXP (XEXP (x, 0), 1));
|
||||
XEXP (x, 0) = gen_rtx_MULT (Pmode,
|
||||
force_reg (Pmode, XEXP (XEXP (x, 0), 0)),
|
||||
GEN_INT (1 << log));
|
||||
@ -5925,9 +5927,10 @@ legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED, enum machine_mode mode)
|
||||
|
||||
if (GET_CODE (XEXP (x, 1)) == ASHIFT
|
||||
&& GET_CODE (XEXP (XEXP (x, 1), 1)) == CONST_INT
|
||||
&& (log = (unsigned) exact_log2 (INTVAL (XEXP (XEXP (x, 1), 1)))) < 4)
|
||||
&& (unsigned HOST_WIDE_INT) INTVAL (XEXP (XEXP (x, 1), 1)) < 4)
|
||||
{
|
||||
changed = 1;
|
||||
log = INTVAL (XEXP (XEXP (x, 1), 1));
|
||||
XEXP (x, 1) = gen_rtx_MULT (Pmode,
|
||||
force_reg (Pmode, XEXP (XEXP (x, 1), 0)),
|
||||
GEN_INT (1 << log));
|
||||
|
@ -1,3 +1,8 @@
|
||||
2005-05-03 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR target/21297
|
||||
* gcc.c-torture/execute/20050502-2.c: New test.
|
||||
|
||||
2005-05-03 Uros Bizjak <uros@kss-loka.si>
|
||||
|
||||
PR middle-end/21282
|
||||
|
34
gcc/testsuite/gcc.c-torture/execute/20050502-2.c
Normal file
34
gcc/testsuite/gcc.c-torture/execute/20050502-2.c
Normal file
@ -0,0 +1,34 @@
|
||||
/* PR target/21297 */
|
||||
typedef __SIZE_TYPE__ size_t;
|
||||
extern int memcmp (const char *, const char *, size_t);
|
||||
extern void abort ();
|
||||
|
||||
void
|
||||
foo (char *x)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 2; i++);
|
||||
x[i + i] = '\0';
|
||||
}
|
||||
|
||||
void
|
||||
bar (char *x)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 2; i++);
|
||||
x[i + i + i + i] = '\0';
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
char x[] = "IJKLMNOPQR";
|
||||
foo (x);
|
||||
if (memcmp (x, "IJKL\0NOPQR", sizeof x) != 0)
|
||||
abort ();
|
||||
x[4] = 'M';
|
||||
bar (x);
|
||||
if (memcmp (x, "IJKLMNOP\0R", sizeof x) != 0)
|
||||
abort ();
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user