Hi all, I'd like to make use of some specific x86 Streaming SIMD Extension instructions, but I don't know where to start. For instance the 'rcpps' instructions computes a low precision but fast reciprocal. I've noticed that LLVM supports intrinsics, but I couldn't find any information on how to use them. I've tried digging through the LLVM-GCC code but it's just too complex for me. I would be very grateful if someone could complete this code: LoadInst *x = new LoadInst(ptr_x, "", false, basicBlock); // y = rcpps(x) // FIXME StoreInst *storeResult = new StoreInst(y, ptr_y, false, basicBlock); Somewhat related to this, I'd also like to know how to 'reinterpret_cast' values. It can be quite useful to sometimes interpret a vector of floating-point values as a vector of integers (for instance to extract the sign, exponent and/or mantissa bits). Any information on how to do that would be much appreciated. Thanks, Nicolas Capens -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080520/a1db13b6/attachment.html>
On Tue, May 20, 2008 at 5:03 AM, Nicolas Capens <nicolas at capens.net> wrote:> LoadInst *x = new LoadInst(ptr_x, "", false, basicBlock); > > // y = rcpps(x) // FIXME > StoreInst *storeResult = new StoreInst(y, ptr_y, false, basicBlock);Using an IRBuilder, something like the following (uncompiled, but it's at least approximately right): Value* x = Builder.CreateLoad(ptr_x); Function* rcpps = Intrinsic::getDeclaration(Module, Intrinsic::x86_sse_rcp_ps); Value* y = Builder.CreateCall(rcpps, x); Builder.CreateStore(y, ptr_y);> Somewhat related to this, I'd also like to know how to 'reinterpret_cast' > values. It can be quite useful to sometimes interpret a vector of > floating-point values as a vector of integers (for instance to extract the > sign, exponent and/or mantissa bits). Any information on how to do that > would be much appreciated.Use the bitcast instruction (see http://llvm.org/docs/LangRef.html). -Eli
Thanks a lot Eli, works like a charm! -----Original Message----- From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Eli Friedman Sent: Tuesday, 20 May, 2008 14:45 To: LLVM Developers Mailing List Subject: Re: [LLVMdev] Making use of SSE intrinsics On Tue, May 20, 2008 at 5:03 AM, Nicolas Capens <nicolas at capens.net> wrote:> LoadInst *x = new LoadInst(ptr_x, "", false, basicBlock); > > // y = rcpps(x) // FIXME > StoreInst *storeResult = new StoreInst(y, ptr_y, false, basicBlock);Using an IRBuilder, something like the following (uncompiled, but it's at least approximately right): Value* x = Builder.CreateLoad(ptr_x); Function* rcpps = Intrinsic::getDeclaration(Module, Intrinsic::x86_sse_rcp_ps); Value* y = Builder.CreateCall(rcpps, x); Builder.CreateStore(y, ptr_y);> Somewhat related to this, I'd also like to know how to 'reinterpret_cast' > values. It can be quite useful to sometimes interpret a vector of > floating-point values as a vector of integers (for instance to extract the > sign, exponent and/or mantissa bits). Any information on how to do that > would be much appreciated.Use the bitcast instruction (see http://llvm.org/docs/LangRef.html). -Eli _______________________________________________ LLVM Developers mailing list LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev