[clang] [llvm] [SPIRV] Add PreLegalizer pattern matching for `faceforward` (PR #139959)
Farzon Lotfi via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 17 08:51:28 PDT 2025
================
@@ -58,3 +58,106 @@ void SPIRVCombinerHelper::applySPIRVDistance(MachineInstr &MI) const {
MI.eraseFromParent();
}
+
+/// This match is part of a combine that
+/// rewrites select(fcmp(dot(I, Ng), 0), N, -N) to faceforward(N, I, Ng)
+/// (vXf32 (g_select
+/// (g_fcmp
+/// (g_intrinsic dot(vXf32 I) (vXf32 Ng)
+/// 0)
+/// (vXf32 N)
+/// (vXf32 g_fneg (vXf32 N))))
+/// ->
+/// (vXf32 (g_intrinsic faceforward
+/// (vXf32 N) (vXf32 I) (vXf32 Ng)))
+///
+/// This only works for Vulkan targets.
----------------
farzonl wrote:
```suggestion
/// This only works for Vulkan shader targets.
```
https://github.com/llvm/llvm-project/pull/139959
More information about the cfe-commits
mailing list