[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");
+ }
----------------
andykaylor wrote:
This assertion is too narrow because multiple variations of the sqrt builtin fall through to this code. I suggest just removing the assertion.
https://github.com/llvm/llvm-project/pull/169310
More information about the cfe-commits
mailing list