[Bug c/13591] New: loop unrolling creates incorrect code with inline asm
shay_gal-on at pmc-sierra dot com
gcc-bugzilla@gcc.gnu.org
Tue Jan 6 21:25:00 GMT 2004
The following code, when compile with -O3 -funroll-loops incorrectly hoists the
inline asm block out of the loop. Various other mods with only inline asm
inside the loop also create incorrect code. E.g. for the code below, if p0 is
volatile, the block is not hoisted, but still loads from an incorrect address
(always loads from the initial p0). If p0 is delared as a (volatile int *), the
code is again hoisted out of the loop.
main (){
int i,a0, a1, a2, a3, p0=0x5555;
for (i=0; i<1000; i=i+1){
__asm__ (
".set noreorder\n\t"
"lw %0, 0(%4)\n\t"
"addiu $0, %0, 0\n\t"
"lw %1, 4096(%4)\n\t"
"addiu $0, %1, 0\n\t"
"lw %2, 2*4096(%4)\n\t"
"addiu $0, %2, 0\n\t"
"lw %3, 3*4096(%4)\n\t"
"addiu $0, %3, 0\n\t"
"addiu $4, %4, 8\n\t"
".set reorder"
: "=r"(a0), "=r"(a1), "=r"(a2), "=r"(a3) :"r"(p0));
}
dummy (a0, a1, a2, a3);
}
dummy(int x, int y, int z, int w){
int result;
result = x + y + z + w;
}
--
Summary: loop unrolling creates incorrect code with inline asm
Product: gcc
Version: 3.3.2
Status: UNCONFIRMED
Severity: critical
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: shay_gal-on at pmc-sierra dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-linux-gnu
GCC host triplet: i686-linux-gnu
GCC target triplet: mipsel-linux-gnu/mips64-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13591
More information about the Gcc-bugs
mailing list