[LLVMbugs] [Bug 10857] New: [AVX] incorrect code generated for simple loop
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sun Sep 4 07:52:35 PDT 2011
http://llvm.org/bugs/show_bug.cgi?id=10857
Summary: [AVX] incorrect code generated for simple loop
Product: new-bugs
Version: trunk
Platform: PC
OS/Version: All
Status: NEW
Severity: normal
Priority: P
Component: new bugs
AssignedTo: unassignedbugs at nondot.org
ReportedBy: matt at pharr.org
CC: llvmbugs at cs.uiuc.edu
Created an attachment (id=7216)
--> (http://llvm.org/bugs/attachment.cgi?id=7216)
llvm asm
The attached short test case represents the compilation of the loop:
void result(float *p) {
for (int i = 0; i < 4; ++i) {
p[2*i+1] = (float)(10+i);
p[2*i] = (float)(14+i);
}
}
(The llvm asm is simple enough that this should be easy to verify by
inspection.)
If I compile it using "llc -O0 -mattr=+avx", incorrect assembly is generated;
the output of the test program indicates that the even array elements aren't
being written to. Correct code is generated with -O2 -mattr=+avx, or if I
don't use the AVX backend.
Here is the result of disassembling the code generated with -O0, avx. (Intel
asm syntax.) Note that the result of the second vcvtsi2ss instruction is never
written to memory, which is aligned with the indication from the test that the
even elements aren't written to.
_result: # Function
.type _result, @function
mov eax, 0 # 0000 _ B8, 00000000
mov dword ptr [rsp-0x4], eax # 0005 _ 89. 44 24, FC
mov qword ptr [rsp-0x10], rdi # 0009 _ 48: 89. 7C 24,
F0
$_001: mov eax, dword ptr [rsp-0x4] # 000E _ 8B. 44 24, FC
# Note: Immediate operand could be made smaller by sign extension
cmp eax, 4 # 0012 _ 3D, 00000004
mov dword ptr [rsp-0x14], eax # 0017 _ 89. 44 24, EC
jl $_003 # 001B _ 7C, 11
jmp $_004 # 001D _ EB, 3E
$_002: mov eax, dword ptr [rsp-0x14] # 001F _ 8B. 44 24, EC
# Note: Immediate operand could be made smaller by sign extension
add eax, 1 # 0023 _ 05, 00000001
mov dword ptr [rsp-0x4], eax # 0028 _ 89. 44 24, FC
jmp $_001 # 002C _ EB, E0
$_003: mov eax, dword ptr [rsp-0x14] # 002E _ 8B. 44 24, EC
mov ecx, dword ptr [rsp-0x14] # 0032 _ 8B. 4C 24, EC
lea eax, [rcx+rax+0x1] # 0036 _ 8D. 44 01, 01
lea edx, [rcx+rcx] # 003A _ 8D. 14 09
movsxd rsi, eax # 003D _ 48: 63. F0
lea eax, [rcx+0xA] # 0040 _ 8D. 41, 0A
vcvtsi2ss xmm0, xmm0, eax # 0043 _ C5 FA: 2A. C0
mov rdi, qword ptr [rsp-0x10] # 0047 _ 48: 8B. 7C 24,
F0
vmovss dword ptr [rdi+rsi*4], xmm0 # 004C _ C5 FA: 11. 04
B7
lea eax, [rcx+0xE] # 0051 _ 8D. 41, 0E
vcvtsi2ss xmm0, xmm0, eax # 0054 _ C5 FA: 2A. C0
movsxd rsi, edx # 0058 _ 48: 63. F2
jmp $_002 # 005B _ EB, C2
$_004: ret # 005D _ C3
.size _result, . - _result # End of function is
probably here
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list