[clang] [CIR][X86]Implement handling for Select/Selectsh builtins in CIR (PR #174003)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 5 10:24:49 PST 2026
================
@@ -184,6 +185,53 @@ static mlir::Value emitX86Select(CIRGenBuilderTy &builder, mlir::Location loc,
return cir::VecTernaryOp::create(builder, loc, mask, op0, op1);
}
+static mlir::Value emitX86ScalarSelect(CIRGenBuilderTy &builder,
+ mlir::Location loc, mlir::Value mask,
+ mlir::Value op0, mlir::Value op1) {
+
+ // If the mask is all ones just return first argument.
+ if (auto c = mlir::dyn_cast_or_null<cir::ConstantOp>(mask.getDefiningOp()))
+ if (c.isAllOnesValue())
+ return op0;
+
+ // Extract the scalar values from the vector operands
+ auto vecTy0 = mlir::dyn_cast<cir::VectorType>(op0.getType());
+ auto vecTy1 = mlir::dyn_cast<cir::VectorType>(op1.getType());
+
+ mlir::Value scalar0 = op0;
+ mlir::Value scalar1 = op1;
+
+ if (vecTy0)
----------------
andykaylor wrote:
Classic codegen extracts these elements before calling this function. Handling vector types in a function named `emitX86ScalarSelect` seems wrong.
https://github.com/llvm/llvm-project/pull/174003
More information about the cfe-commits
mailing list