[LLVMbugs] [Bug 10423] New: I think alignment policy of argument is *too strict*

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Jul 20 05:19:49 PDT 2011


http://llvm.org/bugs/show_bug.cgi?id=10423

           Summary: I think alignment policy of argument is *too strict*
           Product: new-bugs
           Version: 2.9
          Platform: PC
        OS/Version: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: wuye9036 at gmail.com
                CC: llvmbugs at cs.uiuc.edu


Hi, thanks for your attention.

I have a llvm function ( generated by my compiler )

; Dot product.
define float @"Mdot@@QV3F@@QV3F@@"(<3 x float> %.lhs, <3 x float> %.rhs) {
.body:
  %0 = extractelement <3 x float> %.rhs, i32 0
  %1 = extractelement <3 x float> %.lhs, i32 0
  %2 = fmul float %1, %0
  %3 = fadd float 0.000000e+00, %2
  %4 = extractelement <3 x float> %.rhs, i32 1
  %5 = extractelement <3 x float> %.lhs, i32 1
  %6 = fmul float %5, %4
  %7 = fadd float %3, %6
  %8 = extractelement <3 x float> %.rhs, i32 2
  %9 = extractelement <3 x float> %.lhs, i32 2
  %10 = fmul float %9, %8
  %11 = fadd float %7, %10
  ret float %11
}

define float @"Mtest_dot_f3@@QV3F@@QV3F@@"(<3 x float> %lhs, <3 x float> %rhs)
{
.entry:
  br label %.body

.body:                                            ; preds = %.entry
  %0 = call float @"Mdot@@QV3F@@QV3F@@"(<3 x float> %lhs, <3 x float> %rhs)
  ret float %0
                                                  ; No predecessors!
  ret float 0.000000e+00
}

But if I called the JIT-ed function of test_dot_f3 in visual studio(x64),
as following, it is crashed in generated code.

struct vec3{
  float x,y,z;
  // etc.
};

vec3 lhs( 1.9f, 2.7f, -8.1f );
vec3 rhs( -4.8f, 1.1f, 17.5f );

loat (*test_dot_f3)(vec3, vec3) = NULL;

// JIT for get test_dot_f3

float f = test_dot_f3(lhs, rhs); // Crashed!

I analyzed the generated asm, and found:

:cpp function
float f = test_dot_f3(lhs, rhs);
000000013F78F4A5  lea         rax,[rsp+1D8h]  
000000013F78F4AD  mov         qword ptr [rsp+1E8h],rax  
000000013F78F4B5  lea         rax,[rsp+1F0h]  
000000013F78F4BD  mov         qword ptr [rsp+200h],rax  
000000013F78F4C5  lea         rdx,[rsp+118h]  
000000013F78F4CD  mov         rcx,qword ptr [rsp+1E8h]  
000000013F78F4D5  call        eflib::vec3::vec3 (13F7827C0h)  
000000013F78F4DA  mov         qword ptr [rsp+2F0h],rax  
000000013F78F4E2  lea         rdx,[rsp+0E8h]  
000000013F78F4EA  mov         rcx,qword ptr [rsp+200h]  
000000013F78F4F2  call        eflib::vec3::vec3 (13F7827C0h)  
000000013F78F4F7  mov         rcx,qword ptr [rsp+2F0h]  
000000013F78F4FF  mov         rdx,rcx                         ;rdx is 0x23e378
000000013F78F502  mov         rcx,rax  
000000013F78F505  call        qword ptr [rsp+98h]  
000000013F78F50C  movss       dword ptr [rsp+144h],xmm0  

:test_dot_f3
0000000000380014  movaps      xmm0,xmmword ptr [rdx]          ;rdx is 0x23e378,
not 16B aligned. crashed here.
0000000000380017  movaps      xmm1,xmmword ptr [rcx]  
000000000038001A  movaps      xmmword ptr [rsp+30h],xmm1  
000000000038001F  movaps      xmmword ptr [rsp+20h],xmm0

I don't know why temporary is not 16B aligned, and hope to know any solution
for it. 

Thank you all guys !

-- 
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