[clang] [HLSL] Implement support for HLSL intrinsic - select (PR #107129)
Sarah Spall via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 3 14:24:07 PDT 2024
================
@@ -18695,6 +18695,50 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: {
CGM.getHLSLRuntime().getSaturateIntrinsic(), ArrayRef<Value *>{Op0},
nullptr, "hlsl.saturate");
}
+ case Builtin::BI__builtin_hlsl_select: {
+ Value *OpCond = EmitScalarExpr(E->getArg(0));
+ Value *OpTrue = EmitScalarExpr(E->getArg(1));
+ Value *OpFalse = EmitScalarExpr(E->getArg(2));
+ llvm::Type *TCond = OpCond->getType();
+
+ // if cond is a bool emit a select instruction
+ if (TCond->isIntegerTy(1))
+ return Builder.CreateSelect(OpCond, OpTrue, OpFalse, "hlsl.select");
+
+ // if cond is a vector of bools lower to a shufflevector
+ // todo check if that true and false are vectors
----------------
spall wrote:
I likely just forgot to remove them; because yes they were for my own bookkeeping.
https://github.com/llvm/llvm-project/pull/107129
More information about the cfe-commits
mailing list