I want to create a vector version sqrt as the following. Value *Approx::CreateFSqrt(IRBuilder<> &builder, Value *v, const char* Name) { Type *tys[] = {v->getType()}; Module* M = currF->getParent(); Value* sqrtv = Intrinsic::getDeclaration(M, Intrinsic::x86_sse2_sqrt_pd); CallInst *CI = builder.CreateCall(sqrtv, v, Name); return CI; } Here is Value *v is <2 x double> However, it outputs Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type! any idea? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150417/c36b9fbf/attachment.html>
Shahid, Asghar-ahmad
2015-Apr-18 03:50 UTC
[LLVMdev] how can I create an SSE instrinsics sqrt?
Hi zhi, You have to also pass the value type to getDecalaration() API such as Value* sqrtv = Intrinsic::getDeclaration(M, Intrinsic::x86_sse2_sqrt_pd, v->getType()); Regards, Shahid From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of zhi chen Sent: Saturday, April 18, 2015 5:52 AM To: LLVM Dev Subject: [LLVMdev] how can I create an SSE instrinsics sqrt? I want to create a vector version sqrt as the following. Value *Approx::CreateFSqrt(IRBuilder<> &builder, Value *v, const char* Name) { Type *tys[] = {v->getType()}; Module* M = currF->getParent(); Value* sqrtv = Intrinsic::getDeclaration(M, Intrinsic::x86_sse2_sqrt_pd); CallInst *CI = builder.CreateCall(sqrtv, v, Name); return CI; } Here is Value *v is <2 x double> However, it outputs Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type! any idea? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150418/1e186b9c/attachment.html>
Thanks, Shahid. It is fixed now. On Fri, Apr 17, 2015 at 8:50 PM, Shahid, Asghar-ahmad < Asghar-ahmad.Shahid at amd.com> wrote:> Hi zhi, > > > > You have to also pass the value type to getDecalaration() API such as > > > > Value* sqrtv = Intrinsic::getDeclaration(M, Intrinsic::x86_sse2_sqrt_pd, > v->getType()); > > > > Regards, > > Shahid > > > > *From:* llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] *On > Behalf Of *zhi chen > *Sent:* Saturday, April 18, 2015 5:52 AM > *To:* LLVM Dev > *Subject:* [LLVMdev] how can I create an SSE instrinsics sqrt? > > > > I want to create a vector version sqrt as the following. > > > > Value *Approx::CreateFSqrt(IRBuilder<> &builder, Value *v, const char* > Name) { > > Type *tys[] = {v->getType()}; > > Module* M = currF->getParent(); > > Value* sqrtv = Intrinsic::getDeclaration(M, Intrinsic::x86_sse2_sqrt_pd); > > CallInst *CI = builder.CreateCall(sqrtv, v, Name); > > > > return CI; > > } > > > > Here is Value *v is <2 x double> > > However, it outputs Assertion `isa<X>(Val) && "cast<Ty>() argument of > incompatible type! any idea? >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150417/22cac6df/attachment.html>