[clang] [llvm] [HLSL][SPIRV] Added clamp intrinsic (PR #113394)

Adam Yang via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 24 15:41:38 PDT 2024


================
@@ -2559,6 +2559,12 @@ bool SPIRVInstructionSelector::selectIntrinsic(Register ResVReg,
   } break;
   case Intrinsic::spv_saturate:
     return selectSaturate(ResVReg, ResType, I);
+  case Intrinsic::spv_fclamp:
+    return selectExtInst(ResVReg, ResType, I, CL::fclamp, GL::FClamp);
----------------
adam-yang wrote:

looks like `CL::nclamp` doesn't exist, but `CL::fclamp` actually has the same behaviour as `GL::NClamp`: in fmin/fmax, if one of the args is NaN, it returns the other argument.

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


More information about the cfe-commits mailing list