[clang] [CIR][X86] Implement lowering for sqrt builtins (PR #169310)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 24 14:56:16 PST 2025
================
@@ -716,7 +716,19 @@ mlir::Value CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID,
case X86::BI__builtin_ia32_sqrtpd256:
case X86::BI__builtin_ia32_sqrtpd:
case X86::BI__builtin_ia32_sqrtps256:
- case X86::BI__builtin_ia32_sqrtps:
+ case X86::BI__builtin_ia32_sqrtps: {
+ auto loc = getLoc(E->getExprLoc());
+ assert(E->getNumArgs() == 1 && "__builtin_ia32_sqrtps takes one argument");
+ mlir::Value arg = emitScalarExpr(E->getArg(0));
+ mlir::Type argTy = arg.getType();
+ if (auto vecTy = argTy.dyn_cast<mlir::VectorType>()) {
+ assert(vecTy.getNumElements() == 4 &&
+ vecTy.getElementType().isa<mlir::FloatType>() &&
+ "__builtin_ia32_sqrtps expects <4 x float> / __m128");
+ }
+ auto sqrt = builder.create<cir::SqrtOp>(loc, argTy, arg);
----------------
andykaylor wrote:
```suggestion
auto sqrt = cir::SqrtOp>::create(builder, loc, argTy, arg);
```
`auto` is OK here because the type is visible in the source, but the form of `create` you were using here is now deprecated.
https://github.com/llvm/llvm-project/pull/169310
More information about the cfe-commits
mailing list