This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/21990] Wrong code for 4.0 and head: Reload clobbers the frame pointer by using it as spill register without recognizing the clobbering
- From: "bjoern dot haase at de dot bosch dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 Jun 2005 12:10:47 -0000
- Subject: [Bug middle-end/21990] Wrong code for 4.0 and head: Reload clobbers the frame pointer by using it as spill register without recognizing the clobbering
- References: <20050609222806.21990.bjoern.m.haase@web.de>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From bjoern dot haase at de dot bosch dot com 2005-06-10 12:10 -------
Hi,
here is the promised test case. I unfortunately had to use a number of asm
statements in order to reproduce the register contraint combination exposing
the bug. The test case compiles only with -morder1 (== best configuration for
AVR when using many SImode variables) but ICEs otherwise.
Start of testcase:
// Testcase to be compiled with avr-gcc -Os -morder1
#include <inttypes.h>
typedef struct
{
uint32_t HLFG;
} special_struct;
void
foo3 (special_struct *a, const special_struct b)
{
asm (
";"
: "+r" (a->HLFG) : "r" (b.HLFG) );
}
uint16_t inline static
foo (const uint32_t i, const special_struct f)
{ uint16_t ui16_resultat;
asm volatile (
";"
: "=&r" (ui16_resultat)
: "r" (i),
"r" (f.HLFG)
);
return ui16_resultat;
}
special_struct inline static
foo2 (const special_struct m1, const uint16_t m2)
{ special_struct resultat;
asm volatile (
";"
: "=&r" (resultat.HLFG)
: "r" (m1.HLFG),
"r" (m2)
);
if (m1.HLFG & 0x00020000)
{
resultat.HLFG = ~resultat.HLFG;
}
return resultat;
}
special_struct inline static
foo7 (uint16_t t)
{ special_struct resultat;
asm volatile (";" : "=r" (resultat.HLFG):);
if (t & 0x020)
t = ~(t);
if (t & 0x0100)
{
t = ~t;
asm volatile (";" : "+r" (resultat.HLFG):);
}
asm volatile (";" : "+d" (t):);
if (t > 9300)
{
t = 12743 - ( (int16_t) t);
uint16_t ui16_r = 7480;
asm volatile (
";"
: "+&r" (resultat.HLFG)
: "r" (t),
"r" (ui16_r)
);
} else if (t > 9211)
{
uint16_t ui16_r = 1108;
asm volatile (
";"
: "+&r" (resultat.HLFG)
: "r" (t),
"r" (ui16_r)
);
} else
{
uint16_t r = 440;
asm volatile (
";"
: "+&d" (resultat.HLFG),
"+&r" (r)
: "r" (t) );
}
return resultat;
}
typedef struct
{ uint16_t q;
uint16_t a;
} lp_t;
typedef struct
{
lp_t l[19];
uint32_t sf;
} vmt;
vmt m;
special_struct sp_C[19];
special_struct
problem (uint32_t s)
{
special_struct *p_C;
special_struct ga;
ga.HLFG = 0;
p_C = &sp_C[0];
uint8_t lz;
for (lz=0; lz < 23; lz ++)
{
special_struct ac;
{
special_struct C;
C = *p_C;
p_C ++;
uint16_t t;
t = m.l [lz].q;
ac = foo7 ( foo (s, C) - t);
}
{ uint16_t e;
e = m.l [lz].a;
foo3 (&ga, foo2 (ac, e));
}
}
return ga;
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21990