Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HLSL] implement rcp intrinsic #70100

Closed
Tracked by #30
llvm-beanz opened this issue Oct 24, 2023 · 2 comments · Fixed by #83857
Closed
Tracked by #30

[HLSL] implement rcp intrinsic #70100

llvm-beanz opened this issue Oct 24, 2023 · 2 comments · Fixed by #83857
Assignees
Labels
clang:codegen IR generation bugs: mangling, exceptions, etc. clang:frontend Language frontend issues, e.g. anything involving "Sema" HLSL HLSL Language Support

Comments

@llvm-beanz
Copy link
Collaborator

Implement HLSL rcp intrinsic:

https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/rcp

@llvm-beanz llvm-beanz converted this from a draft issue Oct 24, 2023
@llvm-beanz llvm-beanz added the HLSL HLSL Language Support label Oct 24, 2023
@farzonl farzonl self-assigned this Mar 3, 2024
farzonl added a commit to farzonl/llvm-project that referenced this issue Mar 3, 2024
This PR implements the frontend for llvm#70100
This PR is part 1 of 2.
Part 2 depends on dixl-lerp-intrinsic-lowering PR
which will have an intrinsic to instruction expansion pass.
THat pass is what we need to complete the DXIL lowering portion of this
PR:
llvm/[email protected]:llvm-project:dixl-lerp-intrinsic-lowering

Builtins.td - add an rcp builtin
CGBuiltin.cpp add the builtin to intrinsic lowering
hlsl_intrinsics.h - add the rcp  api
SemaChecking.cpp - reuse frac's semachecks
IntrinsicsDirectX.td add the llvm intrinsic
@farzonl farzonl moved this to In Progress in HLSL Support Mar 4, 2024
@farzonl farzonl moved this from In Progress to Needs Review in HLSL Support Mar 4, 2024
farzonl added a commit to farzonl/llvm-project that referenced this issue Mar 5, 2024
This PR implements the frontend for llvm#70100
This PR is part 1 of 2.
Part 2 depends on dixl-lerp-intrinsic-lowering PR
which will have an intrinsic to instruction expansion pass.
THat pass is what we need to complete the DXIL lowering portion of this
PR:
llvm/[email protected]:llvm-project:dixl-lerp-intrinsic-lowering

Builtins.td - add an rcp builtin
CGBuiltin.cpp add the builtin to intrinsic lowering
hlsl_intrinsics.h - add the rcp  api
SemaChecking.cpp - reuse frac's semachecks
IntrinsicsDirectX.td add the llvm intrinsic
@farzonl farzonl moved this from Needs Review to Done in HLSL Support Mar 5, 2024
farzonl added a commit that referenced this issue Mar 5, 2024
This PR implements the frontend for #70100
This PR is part 1 of 2.
Part 2 requires an intrinsic to instructions lowering.


- `Builtins.td` - add an `rcp` builtin
- `CGBuiltin.cpp` - add the builtin to intrinsic lowering
-  `hlsl_intrinsics.h` - add the `rcp`  api
- `SemaChecking.cpp` - reuse frac's sema checks
- `IntrinsicsDirectX.td` - add the llvm intrinsic
farzonl added a commit to farzonl/llvm-project that referenced this issue Mar 8, 2024
This change implements lowering for llvm#70076, llvm#70100, llvm#70072, & llvm#70102
CGBuiltin.cpp - - simplify lerp intrinsic
IntrinsicsDirectX.td - simplify lerp intrinsic
SemaChecking.cpp - remove unnecessary check
DXILIntrinsicExpansion.* - add intrinsic to instruction expansion cases
DXILOpLowering.cpp -  make sure DXILIntrinsicExpansion happens first
DirectX.h - changes to support new pass
DirectXTargetMachine.cpp - changes to support new pass
@farzonl farzonl closed this as completed Mar 12, 2024
@farzonl farzonl linked a pull request Mar 12, 2024 that will close this issue
@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:codegen IR generation bugs: mangling, exceptions, etc. labels Mar 12, 2024
@llvmbot
Copy link
Member

llvmbot commented Mar 12, 2024

@llvm/issue-subscribers-clang-frontend

Author: Chris B (llvm-beanz)

Implement HLSL `rcp` intrinsic:

https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/rcp

@llvmbot
Copy link
Member

llvmbot commented Mar 12, 2024

@llvm/issue-subscribers-clang-codegen

Author: Chris B (llvm-beanz)

Implement HLSL `rcp` intrinsic:

https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/rcp

farzonl added a commit to farzonl/llvm-project that referenced this issue Mar 12, 2024
This change implements lowering for llvm#70076, llvm#70100, llvm#70072, & llvm#70102
CGBuiltin.cpp - - simplify lerp intrinsic
IntrinsicsDirectX.td - simplify lerp intrinsic
SemaChecking.cpp - remove unnecessary check
DXILIntrinsicExpansion.* - add intrinsic to instruction expansion cases
DXILOpLowering.cpp -  make sure DXILIntrinsicExpansion happens first
DirectX.h - changes to support new pass
DirectXTargetMachine.cpp - changes to support new pass
farzonl added a commit to farzonl/llvm-project that referenced this issue Mar 14, 2024
This change implements lowering for llvm#70076, llvm#70100, llvm#70072, & llvm#70102
`CGBuiltin.cpp` - - simplify `lerp` intrinsic
`IntrinsicsDirectX.td` - simplify `lerp` intrinsic
`SemaChecking.cpp` - remove unnecessary check
`DXILIntrinsicExpansion.*` - add intrinsic to instruction expansion cases
`DXILOpLowering.cpp` -  make sure `DXILIntrinsicExpansion` happens first
`DirectX.h` - changes to support new pass
`DirectXTargetMachine.cpp` - changes to support new pass

Why `any`, and `lerp` as instruction expansion just for DXIL?
-  SPIR-V there is an [OpAny](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#OpAny)
- SPIR-V has a GLSL lerp extension via [Fmix](https://registry.khronos.org/SPIR-V/specs/1.0/GLSL.std.450.html#FMix)

Why `exp` instruction expansion?
- We have an `exp2` opcode and `exp` reuses that opcode. So instruction expansion is a convenient way to do preprocessing.
- Further SPIR-V has a GLSL exp extension via  [Exp](https://registry.khronos.org/SPIR-V/specs/1.0/GLSL.std.450.html#Exp) and [Exp2](https://registry.khronos.org/SPIR-V/specs/1.0/GLSL.std.450.html#Exp2)

Why `rcp` as instruction expansion?
This one is a bit of the odd man out and might have to move to `cgbuiltins` when we better understand SPIRV requirements. However I included it because it seems like [fast math mode has an AllowRecip flag](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#_fp_fast_math_mode) which lets you compute the reciprocal without performing the division.  We don't have that in DXIL so thought to include it.
farzonl added a commit that referenced this issue Mar 15, 2024
This change implements lowering for #70076, #70100, #70072, & #70102 
`CGBuiltin.cpp` - - simplify `lerp` intrinsic
`IntrinsicsDirectX.td` - simplify `lerp` intrinsic
`SemaChecking.cpp` - remove unnecessary check
`DXILIntrinsicExpansion.*` - add intrinsic to instruction expansion
cases
`DXILOpLowering.cpp` - make sure `DXILIntrinsicExpansion` happens first
`DirectX.h` - changes to support new pass
`DirectXTargetMachine.cpp` - changes to support new pass

Why `any`, and `lerp` as instruction expansion just for DXIL?
- SPIR-V there is an
[OpAny](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#OpAny)
- SPIR-V has a GLSL lerp extension via
[Fmix](https://registry.khronos.org/SPIR-V/specs/1.0/GLSL.std.450.html#FMix)

Why `exp` instruction expansion?
- We have an `exp2` opcode and `exp` reuses that opcode. So instruction
expansion is a convenient way to do preprocessing.
- Further SPIR-V has a GLSL exp extension via
[Exp](https://registry.khronos.org/SPIR-V/specs/1.0/GLSL.std.450.html#Exp)
and
[Exp2](https://registry.khronos.org/SPIR-V/specs/1.0/GLSL.std.450.html#Exp2)

Why `rcp` as instruction expansion?
This one is a bit of the odd man out and might have to move to
`cgbuiltins` when we better understand SPIRV requirements. However I
included it because it seems like [fast math mode has an AllowRecip
flag](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#_fp_fast_math_mode)
which lets you compute the reciprocal without performing the division.
We don't have that in DXIL so thought to include it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:codegen IR generation bugs: mangling, exceptions, etc. clang:frontend Language frontend issues, e.g. anything involving "Sema" HLSL HLSL Language Support
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants