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

via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 23 08:55:34 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,c,h -- clang/test/SemaSPIRV/BuiltIns/ddx-coarse-errors.c clang/test/SemaSPIRV/BuiltIns/ddy-coarse-errors.c clang/lib/CodeGen/CGHLSLBuiltins.cpp clang/lib/CodeGen/CGHLSLRuntime.h clang/lib/CodeGen/TargetBuiltins/SPIR.cpp clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/lib/Sema/SemaHLSL.cpp clang/lib/Sema/SemaSPIRV.cpp llvm/lib/Target/DirectX/DirectXTargetTransformInfo.cpp llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/CodeGen/CGHLSLBuiltins.cpp b/clang/lib/CodeGen/CGHLSLBuiltins.cpp
index 11faf3123..8abc15b53 100644
--- a/clang/lib/CodeGen/CGHLSLBuiltins.cpp
+++ b/clang/lib/CodeGen/CGHLSLBuiltins.cpp
@@ -843,20 +843,20 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID,
   case Builtin::BI__builtin_hlsl_elementwise_ddx_coarse: {
     Value *Op0 = EmitScalarExpr(E->getArg(0));
     if (!E->getArg(0)->getType()->hasFloatingRepresentation())
-      llvm_unreachable(
-          "ddx_coarse operand must have a float representation");
+      llvm_unreachable("ddx_coarse operand must have a float representation");
     Intrinsic::ID ID = CGM.getHLSLRuntime().getDdxCoarseIntrinsic();
     return Builder.CreateIntrinsic(/*ReturnType=*/Op0->getType(), ID,
-        ArrayRef<Value *>{Op0}, nullptr, "hlsl.ddx.coarse");
+                                   ArrayRef<Value *>{Op0}, nullptr,
+                                   "hlsl.ddx.coarse");
   }
   case Builtin::BI__builtin_hlsl_elementwise_ddy_coarse: {
     Value *Op0 = EmitScalarExpr(E->getArg(0));
     if (!E->getArg(0)->getType()->hasFloatingRepresentation())
-      llvm_unreachable(
-          "ddy_coarse operand must have a float representation");
+      llvm_unreachable("ddy_coarse operand must have a float representation");
     Intrinsic::ID ID = CGM.getHLSLRuntime().getDdyCoarseIntrinsic();
     return Builder.CreateIntrinsic(/*ReturnType=*/Op0->getType(), ID,
-        ArrayRef<Value *>{Op0}, nullptr, "hlsl.ddy.coarse");
+                                   ArrayRef<Value *>{Op0}, nullptr,
+                                   "hlsl.ddy.coarse");
   }
   case Builtin::BI__builtin_get_spirv_spec_constant_bool:
   case Builtin::BI__builtin_get_spirv_spec_constant_short:

``````````

</details>


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


More information about the llvm-commits mailing list