This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/13591] New: loop unrolling creates incorrect code with inline asm


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]