[clang] [llvm] [HLSL] Implement ddx/ddy_coarse intrinsics (PR #164831)

Farzon Lotfi via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 7 09:50:30 PST 2025


================
@@ -3099,6 +3101,66 @@ bool SPIRVInstructionSelector::wrapIntoSpecConstantOp(
   return Result;
 }
 
+bool SPIRVInstructionSelector::selectDpdCoarse(Register ResVReg,
+                                               const SPIRVType *ResType,
+                                               MachineInstr &I,
+                                               const unsigned DPdOpCode) const {
+  if (!STI.isShader()) {
+    std::string DiagMsg;
+    raw_string_ostream OS(DiagMsg);
+    I.print(OS, true, false, false, false);
+    DiagMsg += " is only supported in shaders.\n";
+    report_fatal_error(DiagMsg.c_str(), false);
+  }
----------------
farzonl wrote:

Should this be a helper? I feel like shader checks are going to be needed for more than this one set of opcodes.

Second this actually a bit more restrictive than just shader. the [spec says ](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#OpDPdxCoarse)

> This instruction is only valid in the Fragment [Execution Model](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#Execution_Model).

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


More information about the llvm-commits mailing list