[llvm] Document HLSL SPIR-V intrinsic lowering (PR #213185)

Suren Nihalani via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 30 18:16:53 PDT 2026


https://github.com/SurenNihalani updated https://github.com/llvm/llvm-project/pull/213185

>From c43ae78872919c6879b4cbafb572ff2092ac3280 Mon Sep 17 00:00:00 2001
From: Suren Nihalani <suren at govtron.com>
Date: Thu, 30 Jul 2026 17:55:59 -0700
Subject: [PATCH] [HLSL][SPIRV][Docs] Document intrinsic lowering

---
 llvm/docs/SPIRVUsage.md | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/llvm/docs/SPIRVUsage.md b/llvm/docs/SPIRVUsage.md
index 3ef099be78a61..bd4452e545439 100644
--- a/llvm/docs/SPIRVUsage.md
+++ b/llvm/docs/SPIRVUsage.md
@@ -589,6 +589,39 @@ acos_f32
 represents the `acos` function from the OpenCL extended instruction set for a float32
 input.
 
+#### HLSL Intrinsics
+
+When targeting SPIR-V, Clang lowers HLSL builtin functions to LLVM IR calls that
+the SPIR-V backend recognizes. The backend then selects the corresponding core
+SPIR-V instruction, extended instruction, or instruction sequence. The regression
+tests in `llvm/test/CodeGen/SPIRV/hlsl-intrinsics` show the currently supported
+lowerings.
+
+Some representative HLSL intrinsic mappings are:
+
+```{list-table} HLSL Intrinsic Lowering Examples
+:widths: 20 30 50
+:header-rows: 1
+
+   * - HLSL intrinsic
+     - LLVM IR representation
+     - SPIR-V lowering
+   * - `any`
+     - `llvm.spv.any.*`
+     - Scalar numeric values are compared with zero. Boolean vectors lower to
+       `OpAny`; numeric vectors are first compared elementwise with zero and the
+       resulting boolean vector is reduced with `OpAny`.
+   * - `all`
+     - `llvm.spv.all.*`
+     - Scalar numeric values are compared with zero. Boolean vectors lower to
+       `OpAll`; numeric vectors are first compared elementwise with zero and the
+       resulting boolean vector is reduced with `OpAll`.
+   * - `lerp`
+     - `llvm.spv.lerp.*`
+     - Floating-point scalar and vector forms lower to the GLSL extended
+       instruction `FMix` from `GLSL.std.450`.
+```
+
 #### Builtin Variables
 
 SPIR-V builtin variables, which provide access to special hardware or execution model



More information about the llvm-commits mailing list