[LLVMdev] InstructionCombining forgets alignment of globals

Nicolas Capens nicolas at capens.net
Thu Jul 10 03:18:28 PDT 2008


Hi all,

 

The InstructionCombining pass causes alignment of globals to be ignored.

 

I've attached a replacement of Fibonacci.cpp which reproduces this (I used
2.3 release). Here's the x86 code it produces:

 

03C20019  movaps      xmm0,xmmword ptr ds:[164E799h] 

03C20020  mulps       xmm0,xmmword ptr ds:[164E79Ah] 

03C20027  movaps      xmmword ptr ds:[164E799h],xmm0 

03C2002E  mov         esp,ebp 

03C20030  pop         ebp  

03C20031  ret          

 

All three SSE instructions will generate a fault for accessing unaligned
memory. Disabling InstructionCombining gives me the following correct code:

 

03B10010  push        ebp  

03B10011  mov         ebp,esp 

03B10013  and         esp,0FFFFFFF0h 

03B10019  movups      xmm0,xmmword ptr ds:[164E79Ah] 

03B10020  movups      xmm1,xmmword ptr ds:[164E799h] 

03B10027  mulps       xmm1,xmm0 

03B1002A  movups      xmmword ptr ds:[164E799h],xmm1 

03B10031  mov         esp,ebp 

03B10033  pop         ebp  

03B10034  ret    

 

Unless I'm missing something this is quite clearly a bug. I'll give it a try
to locate the faulty code but all help is very welcome.

 

Cheers,

 

Nicolas Capens

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080710/baa42ec1/attachment.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: fibonacci.cpp
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080710/baa42ec1/attachment.ksh>


More information about the llvm-dev mailing list