[clang] [llvm] [HLSL] Move `normalize` implementation to header files (PR #216228)

Joshua Batista via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 26 16:58:13 PDT 2026


================
@@ -58,6 +58,55 @@ void SPIRVCombinerHelper::applySPIRVDistance(MachineInstr &MI) const {
   MI.eraseFromParent();
 }
 
+/// This match is part of a combine that
+/// rewrites X / length(X) to normalize(X)
+///   (vXf32 (g_fdiv
+///             (vXf32 X)
+///             (vXf32 splat
+///                    (f32 (g_intrinsic length (vXf32 X))))))
+/// ->
+///   (vXf32 (g_intrinsic normalize (vXf32 X)))
+///
+bool SPIRVCombinerHelper::matchFDivToNormalize(MachineInstr &MI) const {
----------------
bob80905 wrote:

Question, why would we want to do this?
The header implementation takes any normalize call and breaks it down into X / length(X). Isn't this just doing the opposite of what the header did for us already?

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


More information about the llvm-commits mailing list