[LLVMdev] problem compiling x86 intrinsic function

Chris Lattner clattner at apple.com
Tue Dec 29 11:57:27 PST 2009


On Dec 29, 2009, at 5:50 AM, fima rabin wrote:

> I am trying to compile this little C-program:
> =================
> typedef double        v2f64 __attribute__((ext_vector_type(2)));
> 
>   int sse2_cmp_sd(v2f64, v2f64, char ) asm("llvm.x86.sse2.cmp.sd");

We used to support this, but there are problems with it.  I actually just went to go implement this again, which illustrated why this is a bad idea.  If you apply this patch to clang, it will do what you want:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p.patch
Type: application/octet-stream
Size: 1040 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20091229/34ec1dd0/attachment.obj>
-------------- next part --------------


The problem with this is that the optimizer and code generator will explode if the generated intrinsic has the wrong attributes or type.  In this case, you have both problems.

Depending directly on llvm intrinsics is also a dangerous thing to do because they are allowed to change over time.  I don't think we want the compiler exposing them directly.  If you need something, there should be a __builtin that corresponds to the intrinsic.

-Chris



More information about the llvm-dev mailing list