[clang] [llvm] [HLSL] Implement the `smoothstep` intrinsic (PR #132288)

Kaitlin Peng via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 21 14:42:11 PDT 2025


================
@@ -20955,6 +20955,25 @@ Value *CodeGenFunction::EmitSPIRVBuiltinExpr(unsigned BuiltinID,
         /*ReturnType=*/I->getType(), Intrinsic::spv_reflect,
         ArrayRef<Value *>{I, N}, nullptr, "spv.reflect");
   }
+  case SPIRV::BI__builtin_spirv_smoothstep: {
+    Value *Min = EmitScalarExpr(E->getArg(0));
+    Value *Max = EmitScalarExpr(E->getArg(1));
+    Value *X = EmitScalarExpr(E->getArg(2));
+    assert(E->getArg(0)->getType()->hasFloatingRepresentation() &&
+           E->getArg(1)->getType()->hasFloatingRepresentation() &&
+           E->getArg(2)->getType()->hasFloatingRepresentation() &&
+           "SmoothStep operands must have a float representation");
+    assert((E->getArg(0)->getType()->isScalarType() ||
----------------
kmpeng wrote:

Code updated with suggested changes.

https://github.com/llvm/llvm-project/pull/132288


More information about the llvm-commits mailing list