[LLVMbugs] [Bug 1233] multi-dimensional VLA indicies not scaled by llvm-gcc

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Thu Mar 1 23:37:55 PST 2007


sabre at nondot.org changed:

           What    |Removed                     |Added
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |2.0

------- Additional Comments From sabre at nondot.org  2007-03-02 01:37 -------
Nice catch.  Testcase here:

Patch here:

The patch generates pretty horrible LLVM code (in the VLA case only), but the code generator groks it 
well.  We compile your testcase to (with fomit-frame-pointer):

        movl 8(%esp), %eax
        imull 12(%esp), %eax
        imull 16(%esp), %eax
        imull 20(%esp), %eax
        movl 36(%esp), %ecx
        addl 32(%esp), %ecx
        imull 28(%esp), %eax
        addl 40(%esp), %ecx
        leal (,%eax,4), %eax
        addl 44(%esp), %ecx
        addl 24(%esp), %eax
        cvttss2si (%eax,%ecx,4), %eax

GCC apparently misses reassociating some arithmetic and does significantly worse:

        pushl   %esi
        movl    24(%esp), %eax
        movl    %eax, %ecx
        imull   20(%esp), %ecx
        movl    %ecx, %edx
        imull   16(%esp), %edx
        movl    %edx, %esi
        imull   12(%esp), %esi
        imull   32(%esp), %esi
        imull   44(%esp), %eax
        imull   40(%esp), %ecx
        imull   36(%esp), %edx
        addl    %edx, %eax
        addl    %ecx, %eax
        addl    48(%esp), %eax
        sall    $2, %eax
        leal    (%eax,%esi,4), %esi
        movl    28(%esp), %eax
        cvttss2si       (%esi,%eax), %eax
        popl    %esi

I'd appreciate it if you could verify that the code we now produce is correct.  I verified a simpler case.

Thanks again for noticing this,


------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

More information about the llvm-bugs mailing list