-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[SPIRV] Added Support for the constrained conversion intrinsics #157437
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
Open
SubashBoopathi
wants to merge
5
commits into
llvm:main
Choose a base branch
from
SubashBoopathi:ConstraintIntrinsics
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ea7d2c2
Experimental Constrained Conversion intrinsics
SubashBoopathi f83218c
Experimental Constrained Conversion intrinsics
SubashBoopathi e0e7243
Constrained-convert.ll test file is updated as per the comments
SubashBoopathi e0423db
Merge branch 'main' into ConstraintIntrinsics
SubashBoopathi e81b7dd
Merge branch 'main' into ConstraintIntrinsics
michalpaszkowski 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
230 changes: 230 additions & 0 deletions
230
llvm/test/CodeGen/SPIRV/llvm-intrinsics/constrained-convert.ll
This file contains hidden or 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,230 @@ | ||
| ; RUN: llc -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s | ||
| ; RUN: %if spirv-tools %{ llc -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %} | ||
|
|
||
| define float @sitofp_f32_i32(i32 %in) { | ||
| ; CHECK-DAG: OpName %[[#]] "conv" | ||
| ; CHECK-DAG: OpConvertSToF %[[#]] %[[#]] | ||
| ; CHECK-DAG: OpDecorate %[[#]] FPRoundingMode RTE | ||
| ; CHECK-DAG: OpReturnValue %[[#]] | ||
| entry: | ||
| %conv = tail call float @llvm.experimental.constrained.sitofp.f32.i32(i32 %in, metadata !"round.tonearest", metadata !"fpexcept.strict") | ||
| ret float %conv | ||
| } | ||
|
|
||
| define float @sitofp_f32_i16(i16 %in) { | ||
| ; CHECK-DAG: OpName %[[#]] "conv1" | ||
| ; CHECK-DAG: OpConvertSToF %[[#]] %[[#]] | ||
| ; CHECK-DAG: OpDecorate %[[#]] FPRoundingMode RTZ | ||
| ; CHECK-DAG: OpReturnValue %[[#]] | ||
| entry: | ||
| %conv1 = tail call float @llvm.experimental.constrained.sitofp.f32.i16(i16 %in, metadata !"round.towardzero", metadata !"fpexcept.strict") | ||
| ret float %conv1 | ||
| } | ||
|
|
||
| define double @sitofp_f64_i16(i16 %in) { | ||
| ; CHECK-DAG: OpName %[[#]] "conv2" | ||
| ; CHECK-DAG: OpConvertSToF %[[#]] %[[#]] | ||
| ; CHECK-DAG: OpDecorate %[[#]] FPRoundingMode RTP | ||
| ; CHECK-DAG: OpReturnValue %[[#]] | ||
| entry: | ||
| %conv2 = tail call double @llvm.experimental.constrained.sitofp.f64.i16(i16 %in, metadata !"round.upward", metadata !"fpexcept.strict") | ||
| ret double %conv2 | ||
| } | ||
|
|
||
| define double @sitofp_f64_i32(i16 %in) { | ||
| ; CHECK-DAG: OpName %[[#]] "conv3" | ||
| ; CHECK-DAG: OpConvertSToF %[[#]] %[[#]] | ||
| ; CHECK-DAG: OpDecorate %[[#]] FPRoundingMode RTN | ||
| ; CHECK-DAG: OpReturnValue %[[#]] | ||
| entry: | ||
| %conv3 = tail call double @llvm.experimental.constrained.sitofp.f64.i32(i16 %in, metadata !"round.downward", metadata !"fpexcept.strict") | ||
| ret double %conv3 | ||
| } | ||
|
|
||
| define <4 x double> @sitofp_v4f64_v4i32(<4 x i16> %in) { | ||
| ; CHECK-DAG: OpName %[[#]] "conv4" | ||
| ; CHECK-DAG: OpConvertSToF %[[#]] %[[#]] | ||
| ; CHECK-DAG: OpDecorate %[[#]] FPRoundingMode RTE | ||
| ; CHECK-DAG: OpReturnValue %[[#]] | ||
| entry: | ||
| %conv4 = tail call <4 x double> @llvm.experimental.constrained.sitofp.v4f64.v4i32(<4 x i16> %in, metadata !"round.tonearest", metadata !"fpexcept.strict") | ||
| ret <4 x double> %conv4 | ||
| } | ||
|
|
||
| define float @uitofp_f32_i32(i32 %in) { | ||
| ; CHECK-DAG: OpName %[[#]] "conv5" | ||
| ; CHECK-DAG: OpConvertUToF %[[#]] %[[#]] | ||
| ; CHECK-DAG: OpDecorate %[[#]] FPRoundingMode RTE | ||
| ; CHECK-DAG: OpReturnValue %[[#]] | ||
| entry: | ||
| %conv5 = tail call float @llvm.experimental.constrained.uitofp.f32.i32(i32 %in, metadata !"round.tonearest", metadata !"fpexcept.strict") | ||
| ret float %conv5 | ||
| } | ||
|
|
||
| define double @uitofp_f64_i32(i32 %in) { | ||
| ; CHECK-DAG: OpName %[[#]] "conv6" | ||
| ; CHECK-DAG: OpConvertUToF %[[#]] %[[#]] | ||
| ; CHECK-DAG: OpDecorate %[[#]] FPRoundingMode RTZ | ||
| ; CHECK-DAG: OpReturnValue %[[#]] | ||
| entry: | ||
| %conv6 = tail call double @llvm.experimental.constrained.uitofp.f64.i32(i32 %in, metadata !"round.towardzero", metadata !"fpexcept.strict") | ||
| ret double %conv6 | ||
| } | ||
|
|
||
| define float @uitofp_f32_i16(i16 %in) { | ||
| ; CHECK-DAG: OpName %[[#]] "conv7" | ||
| ; CHECK-DAG: OpConvertUToF %[[#]] %[[#]] | ||
| ; CHECK-DAG: OpDecorate %[[#]] FPRoundingMode RTP | ||
| ; CHECK-DAG: OpReturnValue %[[#]] | ||
| entry: | ||
| %conv7 = tail call float @llvm.experimental.constrained.uitofp.f32.i16(i16 %in, metadata !"round.upward", metadata !"fpexcept.strict") | ||
| ret float %conv7 | ||
| } | ||
|
|
||
| define double @uitofp_f64_i16(i16 %in) { | ||
| ; CHECK-DAG: OpName %[[#]] "conv8" | ||
| ; CHECK-DAG: OpConvertUToF %[[#]] %[[#]] | ||
| ; CHECK-DAG: OpDecorate %[[#]] FPRoundingMode RTN | ||
| ; CHECK-DAG: OpReturnValue %[[#]] | ||
| entry: | ||
| %conv8 = tail call double @llvm.experimental.constrained.uitofp.f64.i16(i16 %in, metadata !"round.downward", metadata !"fpexcept.strict") | ||
| ret double %conv8 | ||
| } | ||
|
|
||
| define <4 x float> @uitofp_v4f32_v4i32(<4 x i32> %in) { | ||
| ; CHECK-DAG: OpName %[[#]] "conv9" | ||
| ; CHECK-DAG: OpConvertUToF %[[#]] %[[#]] | ||
| ; CHECK-DAG: OpDecorate %[[#]] FPRoundingMode RTE | ||
| ; CHECK-DAG: OpReturnValue %[[#]] | ||
| entry: | ||
| %conv9 = tail call <4 x float> @llvm.experimental.constrained.uitofp.v4f32.v4i32(<4 x i32> %in, metadata !"round.tonearest", metadata !"fpexcept.strict") | ||
| ret <4 x float> %conv9 | ||
| } | ||
|
|
||
| define i32 @fptosi_i32_f32(float %in) { | ||
| ; CHECK-DAG: OpName %[[#]] "conv10" | ||
| ; CHECK-DAG: OpConvertFToS %[[#]] %[[#]] | ||
| ; CHECK-DAG: OpReturnValue %[[#]] | ||
| entry: | ||
| %conv10 = tail call i32 @llvm.experimental.constrained.fptosi.i32.f32(float %in, metadata !"fpexcept.strict") | ||
| ret i32 %conv10 | ||
| } | ||
|
|
||
| define i32 @fptosi_i32_f64(double %in) { | ||
| ; CHECK-DAG: OpName %[[#]] "conv11" | ||
| ; CHECK-DAG: OpConvertFToS %[[#]] %[[#]] | ||
| ; CHECK-DAG: OpReturnValue %[[#]] | ||
| entry: | ||
| %conv11 = tail call i32 @llvm.experimental.constrained.fptosi.i32.f64(double %in, metadata !"fpexcept.strict") | ||
| ret i32 %conv11 | ||
| } | ||
|
|
||
| define i16 @fptosi_i16_f32(float %in) { | ||
| ; CHECK-DAG: OpName %[[#]] "conv12" | ||
| ; CHECK-DAG: OpConvertFToS %[[#]] %[[#]] | ||
| ; CHECK-DAG: OpReturnValue %[[#]] | ||
| entry: | ||
| %conv12 = tail call i16 @llvm.experimental.constrained.fptosi.i16.f64(float %in, metadata !"fpexcept.strict") | ||
| ret i16 %conv12 | ||
| } | ||
|
|
||
| define i16 @fptosi_i16_f64(double %in) { | ||
| ; CHECK-DAG: OpName %[[#]] "conv13" | ||
| ; CHECK-DAG: OpConvertFToS %[[#]] %[[#]] | ||
| ; CHECK-DAG: OpReturnValue %[[#]] | ||
| entry: | ||
| %conv13 = tail call i16 @llvm.experimental.constrained.fptosi.i16.f64(double %in, metadata !"fpexcept.strict") | ||
| ret i16 %conv13 | ||
| } | ||
|
|
||
| define <4 x i16> @fptosi_v4i16_v4f64(<4 x double> %in) { | ||
| ; CHECK-DAG: OpName %[[#]] "conv14" | ||
| ; CHECK-DAG: OpConvertFToS %[[#]] %[[#]] | ||
| ; CHECK-DAG: OpReturnValue %[[#]] | ||
| entry: | ||
| %conv14 = tail call <4 x i16> @llvm.experimental.constrained.fptosi.v4i16.v4f64(<4 x double> %in, metadata !"fpexcept.strict") | ||
| ret <4 x i16> %conv14 | ||
| } | ||
|
|
||
| define i32 @fptoui_i32_f32(float %in) { | ||
| ; CHECK-DAG: OpName %[[#]] "conv15" | ||
| ; CHECK-DAG: OpConvertFToU %[[#]] %[[#]] | ||
| ; CHECK-DAG: OpReturnValue %[[#]] | ||
| entry: | ||
| %conv15 = tail call i32 @llvm.experimental.constrained.fptoui.i32.f32(float %in, metadata !"fpexcept.strict") | ||
| ret i32 %conv15 | ||
| } | ||
|
|
||
| define i32 @fptoui_i32_f64(double %in) { | ||
| ; CHECK-DAG: OpName %[[#]] "conv16" | ||
| ; CHECK-DAG: OpConvertFToU %[[#]] %[[#]] | ||
| ; CHECK-DAG: OpReturnValue %[[#]] | ||
| entry: | ||
| %conv16 = tail call i32 @llvm.experimental.constrained.fptoui.i32.f64(double %in, metadata !"fpexcept.strict") | ||
| ret i32 %conv16 | ||
| } | ||
|
|
||
| define i16 @fptoui_i16_f32(float %in) { | ||
| ; CHECK-DAG: OpName %[[#]] "conv17" | ||
| ; CHECK-DAG: OpConvertFToU %[[#]] %[[#]] | ||
| ; CHECK-DAG: OpReturnValue %[[#]] | ||
| entry: | ||
| %conv17 = tail call i16 @llvm.experimental.constrained.fptoui.i16.f32(float %in, metadata !"fpexcept.strict") | ||
| ret i16 %conv17 | ||
| } | ||
|
|
||
| define i16 @fptoui_i16_f64(double %in) { | ||
| ; CHECK-DAG: OpName %[[#]] "conv18" | ||
| ; CHECK-DAG: OpConvertFToU %[[#]] %[[#]] | ||
| ; CHECK-DAG: OpReturnValue %[[#]] | ||
| entry: | ||
| %conv18 = tail call i16 @llvm.experimental.constrained.fptoui.i16.f64(double %in, metadata !"fpexcept.strict") | ||
| ret i16 %conv18 | ||
| } | ||
|
|
||
| define <4 x i32> @fptoui_v4i32_v4f64(<4 x double> %in) { | ||
| ; CHECK-DAG: OpName %[[#]] "conv19" | ||
| ; CHECK-DAG: OpConvertFToU %[[#]] %[[#]] | ||
| ; CHECK-DAG: OpReturnValue %[[#]] | ||
| entry: | ||
| %conv19 = tail call <4 x i32> @llvm.experimental.constrained.fptoui.v4i32.v4f64(<4 x double> %in, metadata !"fpexcept.strict") | ||
| ret <4 x i32> %conv19 | ||
| } | ||
|
|
||
| define double @fpext_f64_f32(float %in) { | ||
| ; CHECK-DAG: OpName %[[#]] "conv20" | ||
| ; CHECK-DAG: OpFConvert %[[#]] %[[#]] | ||
| ; CHECK-DAG: OpReturnValue %[[#]] | ||
| entry: | ||
| %conv20 = tail call double @llvm.experimental.constrained.fpext.f64.f32(float %in, metadata !"fpexcept.strict") | ||
| ret double %conv20 | ||
| } | ||
|
|
||
| define <4 x double> @fpext_v4f64_v4f32(<4 x float> %in) { | ||
| ; CHECK-DAG: OpName %[[#]] "conv21" | ||
| ; CHECK-DAG: OpFConvert %[[#]] %[[#]] | ||
| ; CHECK-DAG: OpReturnValue %[[#]] | ||
| entry: | ||
| %conv21 = tail call <4 x double> @llvm.experimental.constrained.fpext.v4f64.v4f32(<4 x float> %in, metadata !"fpexcept.strict") | ||
| ret <4 x double> %conv21 | ||
| } | ||
|
|
||
| define <4 x float> @fptrunc_v4f32_v4f64(<4 x double> %in) { | ||
| ; CHECK-DAG: OpName %[[#]] "conv22" | ||
| ; CHECK-DAG: OpFConvert %[[#]] %[[#]] | ||
| ; CHECK-DAG: OpDecorate %[[#]] FPRoundingMode RTZ | ||
| ; CHECK-DAG: OpReturnValue %[[#]] | ||
| entry: | ||
| %conv22 = tail call <4 x float> @llvm.experimental.constrained.fptrunc.v4f32.v4f64(<4 x double> %in, metadata !"round.towardzero", metadata !"fpexcept.strict") | ||
| ret <4 x float> %conv22 | ||
| } | ||
|
|
||
| define float @fptrunc_f32_f64(double %in) { | ||
| ; CHECK-DAG: OpName %[[#]] "conv23" | ||
| ; CHECK-DAG: OpFConvert %[[#]] %[[#]] | ||
| ; CHECK-DAG: OpDecorate %[[#]] FPRoundingMode RTE | ||
| ; CHECK-DAG: OpReturnValue %[[#]] | ||
| entry: | ||
| %conv23 = tail call float @llvm.experimental.constrained.fptrunc.f32.f64(double %in, metadata !"round.tonearest", metadata !"fpexcept.strict") | ||
| ret float %conv23 | ||
| } | ||
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.
No check label, and don't need CHECK-DAG. Can you just use update_llc_test_checks
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.
@arsenm I tried running utils/update_llc_test_checks.py on constrained-convert.ll. Instead of regenerating the CHECK: directives, it only inserted the autogenerated note at the top and the file end marker, while removing the existing checks in between. Could you clarify the correct way to use the script here?
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.
Did it print a warning on error? Somehow only 2 spirv tests are using update_llc_test_checks. Is it getting confused by the second run line?
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.
@arsenm Yes, it did print a warning message: WARNING: Skipping non-llc RUN line.
When I removed the second RUN line, the warning disappeared, but the issue still persists — the script removes the existing CHECK: directives and only adds the autogenerated note at the top and the file end marker.
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.
Gentle reminder @arsenm any updates on this PR?