[LLVMbugs] [Bug 1233] multi-dimensional VLA indicies not scaled by llvm-gcc
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Fri Mar 2 15:40:51 PST 2007
http://llvm.org/bugs/show_bug.cgi?id=1233
sabre at nondot.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
Resolution| |FIXED
Version|1.9 |1.0
------- Additional Comments From sabre at nondot.org 2007-03-02 17:40 -------
Okay, here's the second half of the patch, which handles the ARRAY_REF array case (previous patch
handled ARRAY_REF pointer case):
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070226/045418.html
With this, we now compile:
int foo(int v, int w, int x, int y, int z,
float A[][w][x],
int g, int h, int i, int j, int k){
return A[g][10000][0];
}
into:
_foo:
movl 28(%esp), %eax
imull 8(%esp), %eax
leal 40000(,%eax,4), %eax
imull 12(%esp), %eax
movl 24(%esp), %ecx
cvttss2si (%ecx,%eax), %eax
ret
... which looks right to me.
GCC produces this, which is also right, but just worse code:
_foo:
movl 12(%esp), %eax
movl %eax, %edx
imull 8(%esp), %edx
imull $40000, %eax, %eax
imull 28(%esp), %edx
leal (%eax,%edx,4), %edx
movl 24(%esp), %eax
cvttss2si (%edx,%eax), %eax
retÂ
We now compile your full case to:
_foo2:
movl 8(%esp), %eax
imull 28(%esp), %eax
addl 32(%esp), %eax
imull 12(%esp), %eax
addl 36(%esp), %eax
imull 16(%esp), %eax
addl 40(%esp), %eax
imull 20(%esp), %eax
addl 44(%esp), %eax
movl 24(%esp), %ecx
cvttss2si (%ecx,%eax,4), %eax
ret
GCC produces:
_foo2:
pushl %esi
movl 24(%esp), %eax
movl %eax, %ecx
imull 20(%esp), %ecx
imull 44(%esp), %eax
movl %ecx, %edx
imull 16(%esp), %edx
imull 40(%esp), %ecx
movl %edx, %esi
imull 36(%esp), %edx
imull 12(%esp), %esi
imull 32(%esp), %esi
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
ret
Please verify that the new codegen is correct. Thanks again,
-Chris
------- 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