llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[SPIRV][DirectX][HLSL] Move `normalize` implementation to `hlsl_intrinsics.h`

Open farzonl opened this issue 1 year ago • 5 comments

  1. Remove Intrinsic::dx_normalize
  2. Remove BI__builtin_hlsl_normalize
  3. Remove BI__builtin_hlsl_normalize Sema checks from clang/lib/Sema/SemaHLSL.cpp
  4. Remove getNormalizeIntrinsic from clang/lib/CodeGen/CGHLSLRuntime.h
  5. Remove emitting intrinsic from clang/lib/CodeGen/CGBuiltin.cpp
  6. Remove expandNormalizeIntrinsic in llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp
  7. Implement normalize algorithmicly in hlsl_intrinsics.h
  8. Add a pattern match for normalize as an InstCombine in llvm/lib/Target/SPIRV/SPIRVPreLegalizerCombiner.cpp to be able to still emit the normalize GL extension.

farzonl avatar Feb 20 '25 18:02 farzonl

@damyanp moving this to Q3.

We should move radians, step, lerp, & degrees.

farzonl avatar Jul 30 '26 18:07 farzonl

may need to move sign aswell.

farzonl avatar Jul 30 '26 18:07 farzonl

Update on step 8/the SPIR-V side: we will do the pattern matching approach over the spirv builtin fast path. Pattern matching will be done in the same PR, not as a follow-up.

kmpeng avatar Aug 07 '26 23:08 kmpeng

@llvm/issue-subscribers-clang-frontend

Author: Farzon Lotfi (farzonl)

1. Remove `Intrinsic::dx_normalize` 2. Remove `BI__builtin_hlsl_normalize` 3. Remove `BI__builtin_hlsl_normalize` Sema checks from `clang/lib/Sema/SemaHLSL.cpp` 4. Remove `getNormalizeIntrinsic` from `clang/lib/CodeGen/CGHLSLRuntime.h` 5. Remove emitting intrinsic from `clang/lib/CodeGen/CGBuiltin.cpp` 6. Remove `expandNormalizeIntrinsic` in `llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp` 7. Implement normalize algorithmicly in `hlsl_intrinsics.h` 8. Add a pattern match for `normalize` as an InstCombine in `llvm/lib/Target/SPIRV/SPIRVPreLegalizerCombiner.cpp` to be able to still emit the `normalize` GL extension.

@llvm/issue-subscribers-clang-codegen

Author: Farzon Lotfi (farzonl)

1. Remove `Intrinsic::dx_normalize` 2. Remove `BI__builtin_hlsl_normalize` 3. Remove `BI__builtin_hlsl_normalize` Sema checks from `clang/lib/Sema/SemaHLSL.cpp` 4. Remove `getNormalizeIntrinsic` from `clang/lib/CodeGen/CGHLSLRuntime.h` 5. Remove emitting intrinsic from `clang/lib/CodeGen/CGBuiltin.cpp` 6. Remove `expandNormalizeIntrinsic` in `llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp` 7. Implement normalize algorithmicly in `hlsl_intrinsics.h` 8. Add a pattern match for `normalize` as an InstCombine in `llvm/lib/Target/SPIRV/SPIRVPreLegalizerCombiner.cpp` to be able to still emit the `normalize` GL extension.