-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
[SPIRV] Add radians intrinsic #110800
Merged
Merged
[SPIRV] Add radians intrinsic #110800
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
010cf37
Added radians selection for spirv
adam-yang ea6331e
Added nomem attribute
adam-yang 735e8be
Fixed bad rebase. Removed selectRadians and using selectExtInst instead
adam-yang 0ab8d0f
Added test variant for opencl
adam-yang 17175f2
Separated the opencl test to its own thing
adam-yang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s | ||
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %} | ||
|
||
; CHECK-DAG: %[[#op_ext_glsl:]] = OpExtInstImport "GLSL.std.450" | ||
|
||
; CHECK-DAG: %[[#float_32:]] = OpTypeFloat 32 | ||
; CHECK-DAG: %[[#float_16:]] = OpTypeFloat 16 | ||
|
||
; CHECK-DAG: %[[#vec4_float_32:]] = OpTypeVector %[[#float_32]] 4 | ||
; CHECK-DAG: %[[#vec4_float_16:]] = OpTypeVector %[[#float_16]] 4 | ||
|
||
declare half @llvm.spv.radians.f16(half) | ||
declare float @llvm.spv.radians.f32(float) | ||
|
||
declare <4 x float> @llvm.spv.radians.v4f32(<4 x float>) | ||
declare <4 x half> @llvm.spv.radians.v4f16(<4 x half>) | ||
|
||
define noundef float @radians_float(float noundef %a) { | ||
entry: | ||
; CHECK: %[[#float_32_arg:]] = OpFunctionParameter %[[#float_32]] | ||
; CHECK: %[[#]] = OpExtInst %[[#float_32]] %[[#op_ext_glsl]] Radians %[[#float_32_arg]] | ||
%elt.radians = call float @llvm.spv.radians.f32(float %a) | ||
ret float %elt.radians | ||
} | ||
|
||
define noundef half @radians_half(half noundef %a) { | ||
entry: | ||
; CHECK: %[[#float_16_arg:]] = OpFunctionParameter %[[#float_16]] | ||
; CHECK: %[[#]] = OpExtInst %[[#float_16]] %[[#op_ext_glsl]] Radians %[[#float_16_arg]] | ||
%elt.radians = call half @llvm.spv.radians.f16(half %a) | ||
ret half %elt.radians | ||
} | ||
|
||
define noundef <4 x float> @radians_float_vector(<4 x float> noundef %a) { | ||
entry: | ||
; CHECK: %[[#vec4_float_32_arg:]] = OpFunctionParameter %[[#vec4_float_32]] | ||
; CHECK: %[[#]] = OpExtInst %[[#vec4_float_32]] %[[#op_ext_glsl]] Radians %[[#vec4_float_32_arg]] | ||
%elt.radians = call <4 x float> @llvm.spv.radians.v4f32(<4 x float> %a) | ||
ret <4 x float> %elt.radians | ||
} | ||
|
||
define noundef <4 x half> @radians_half_vector(<4 x half> noundef %a) { | ||
entry: | ||
; CHECK: %[[#vec4_float_16_arg:]] = OpFunctionParameter %[[#vec4_float_16]] | ||
; CHECK: %[[#]] = OpExtInst %[[#vec4_float_16]] %[[#op_ext_glsl]] Radians %[[#vec4_float_16_arg]] | ||
%elt.radians = call <4 x half> @llvm.spv.radians.v4f16(<4 x half> %a) | ||
ret <4 x half> %elt.radians | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s | ||
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s | ||
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %} | ||
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %} | ||
|
||
; CHECK-DAG: %[[#op_ext_glsl:]] = OpExtInstImport "OpenCL.std" | ||
|
||
; CHECK-DAG: %[[#float_32:]] = OpTypeFloat 32 | ||
; CHECK-DAG: %[[#float_16:]] = OpTypeFloat 16 | ||
|
||
; CHECK-DAG: %[[#vec4_float_32:]] = OpTypeVector %[[#float_32]] 4 | ||
; CHECK-DAG: %[[#vec4_float_16:]] = OpTypeVector %[[#float_16]] 4 | ||
|
||
declare half @llvm.spv.radians.f16(half) | ||
declare float @llvm.spv.radians.f32(float) | ||
|
||
declare <4 x float> @llvm.spv.radians.v4f32(<4 x float>) | ||
declare <4 x half> @llvm.spv.radians.v4f16(<4 x half>) | ||
|
||
define noundef float @radians_float(float noundef %a) { | ||
entry: | ||
; CHECK: %[[#float_32_arg:]] = OpFunctionParameter %[[#float_32]] | ||
; CHECK: %[[#]] = OpExtInst %[[#float_32]] %[[#op_ext_glsl]] radians %[[#float_32_arg]] | ||
%elt.radians = call float @llvm.spv.radians.f32(float %a) | ||
ret float %elt.radians | ||
} | ||
|
||
define noundef half @radians_half(half noundef %a) { | ||
entry: | ||
; CHECK: %[[#float_16_arg:]] = OpFunctionParameter %[[#float_16]] | ||
; CHECK: %[[#]] = OpExtInst %[[#float_16]] %[[#op_ext_glsl]] radians %[[#float_16_arg]] | ||
%elt.radians = call half @llvm.spv.radians.f16(half %a) | ||
ret half %elt.radians | ||
} | ||
|
||
define noundef <4 x float> @radians_float_vector(<4 x float> noundef %a) { | ||
entry: | ||
; CHECK: %[[#vec4_float_32_arg:]] = OpFunctionParameter %[[#vec4_float_32]] | ||
; CHECK: %[[#]] = OpExtInst %[[#vec4_float_32]] %[[#op_ext_glsl]] radians %[[#vec4_float_32_arg]] | ||
%elt.radians = call <4 x float> @llvm.spv.radians.v4f32(<4 x float> %a) | ||
ret <4 x float> %elt.radians | ||
} | ||
|
||
define noundef <4 x half> @radians_half_vector(<4 x half> noundef %a) { | ||
entry: | ||
; CHECK: %[[#vec4_float_16_arg:]] = OpFunctionParameter %[[#vec4_float_16]] | ||
; CHECK: %[[#]] = OpExtInst %[[#vec4_float_16]] %[[#op_ext_glsl]] radians %[[#vec4_float_16_arg]] | ||
%elt.radians = call <4 x half> @llvm.spv.radians.v4f16(<4 x half> %a) | ||
ret <4 x half> %elt.radians | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a test for CL::radians?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified the test to also test the CL variant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't use the opencl extension in hlsl though. Even though this is an easy test change
llvm/test/CodeGen/SPIRV/hlsl-intrinsics
tests should be devoted to how HLSL does things. I feel like the folks that care about opencl should be adding opencl tests to their parts of the test directory.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CL variant could support double type and vector2/3/4/8/16.
It would be nice to have these tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have a common place to test things like int_spv_radians so that we can share the same test with different run lines, similar to what Adam did in radians.ll?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ll let other folks weigh in. I was afraid of testing scope creep. We do want a set of tests that are hlsl only. The question is do we want to be on the hook for opencl tests and do we want to go and update every hlsl intrinsic to have cl tests as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are adding the
spv_radians
->cl::radians
lowering code path, so we should test it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats because
selectExtInst
defined in such a way where GL is optional but CL is required. Also I'm not against testingcl::radians
. I just don't think it should be a part of thellvm/test/CodeGen/SPIRV/hlsl-intrinsics
test suite.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I separated the cl specific tests to llvm/test/CodeGen/SPIRV/opencl/radians.ll
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adam-yang Thank you!