undefined reference to 'llvm.x86.sse2.sqrt.pd.v2f64'

I used the following way to create an x86_sse2_sqrt_pd intrinsic instruction:

Value *Approx::CreateVFSqrt(IRBuilder<> &builder, Value *v, const std::string& Name) {
Type tys[] = {v->getType()};
Module
M = currF->getParent();

Value* sqrtv = Intrinsic::getDeclaration(M, Intrinsic::x86_sse2_sqrt_pd, tys);
Value *CI = builder.CreateCall(sqrtv, v, Name);

return CI;
}

I can compile it with clang++ and then generate the assembly code with llc.

However, it gives me and error “undefined reference to ‘llvm.x86.sse2.sqrt.pd.v2f64’” when I want to generate the executable with gcc. BTW, I opened the assembly code and I can see an instruction “calll llvm.x86.sse2.sqrt.pd.v2f64” in the file. Any hint would be appreciated!

Best,
Zhi

It’s fixed. I can just use intrinsic::sqrt instead of x86_sse_sqrt_pd.