[clang] [CIR][X86]Implement handling for Select/Selectsh builtins in CIR (PR #174003)
Priyanshu Kumar via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 1 21:27:21 PST 2026
================
@@ -184,6 +184,37 @@ 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;
+ // Cast to cir::IntType to safely get the width of a CIR integer
+ unsigned width = 0;
+ if (auto intTy = mlir::dyn_cast<cir::IntType>(mask.getType())) {
+ width = intTy.getWidth();
+ } else {
+ // Fallback or handle unexpected type
+ width = 8;
----------------
Priyanshu3820 wrote:
yes, that would be better. Done
https://github.com/llvm/llvm-project/pull/174003
More information about the cfe-commits
mailing list