-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[SPIRV] Added support for the constrained arithmetic intrinsic #157441
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
4
commits into
llvm:main
Choose a base branch
from
SubashBoopathi:constrained_fmuladd
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.
+71
−0
Open
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d512507
Added Support for the Constrained fmuladd
SubashBoopathi 61dad88
Removed the legalization of the Opcode and used lower()
SubashBoopathi 082c8aa
Slight changes in the format of legalizerinfo
SubashBoopathi b9d3905
Modified the legalization conditions to lower the instruction directly
SubashBoopathi 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
64 changes: 64 additions & 0 deletions
64
llvm/test/CodeGen/SPIRV/llvm-intrinsics/constrained-fmuladd.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,64 @@ | ||
| ; 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 %} | ||
|
|
||
| ; CHECK-DAG: OpDecorate %[[#]] FPRoundingMode RTE | ||
| ; CHECK-DAG: OpDecorate %[[#]] FPRoundingMode RTZ | ||
| ; CHECK-DAG: OpDecorate %[[#]] FPRoundingMode RTP | ||
| ; CHECK-DAG: OpDecorate %[[#]] FPRoundingMode RTN | ||
| ; CHECK-DAG: OpDecorate %[[#]] FPRoundingMode RTE | ||
|
|
||
| ; CHECK: OpFMul %[[#]] %[[#]] %[[#]] | ||
| ; CHECK: OpFAdd %[[#]] %[[#]] %[[#]] | ||
| define spir_kernel void @test_f32(float %a) { | ||
| entry: | ||
| %r = tail call float @llvm.experimental.constrained.fmuladd.f32( | ||
| float %a, float %a, float %a, | ||
| metadata !"round.tonearest", metadata !"fpexcept.strict") | ||
| ret void | ||
| } | ||
|
|
||
| ; CHECK: OpFMul %[[#]] %[[#]] %[[#]] | ||
| ; CHECK: OpFAdd %[[#]] %[[#]] %[[#]] | ||
| define spir_kernel void @test_f64(double %a) { | ||
| entry: | ||
| %r = tail call double @llvm.experimental.constrained.fmuladd.f64( | ||
| double %a, double %a, double %a, | ||
| metadata !"round.towardzero", metadata !"fpexcept.strict") | ||
| ret void | ||
| } | ||
|
|
||
| ; CHECK: OpFMul %[[#]] %[[#]] %[[#]] | ||
| ; CHECK: OpFAdd %[[#]] %[[#]] %[[#]] | ||
| define spir_kernel void @test_v2f32(<2 x float> %a) { | ||
| entry: | ||
| %r = tail call <2 x float> @llvm.experimental.constrained.fmuladd.v2f32( | ||
| <2 x float> %a, <2 x float> %a, <2 x float> %a, | ||
| metadata !"round.upward", metadata !"fpexcept.strict") | ||
| ret void | ||
| } | ||
|
|
||
| ; CHECK: OpFMul %[[#]] %[[#]] %[[#]] | ||
| ; CHECK: OpFAdd %[[#]] %[[#]] %[[#]] | ||
| define spir_kernel void @test_v4f32(<4 x float> %a) { | ||
| entry: | ||
| %r = tail call <4 x float> @llvm.experimental.constrained.fmuladd.v4f32( | ||
| <4 x float> %a, <4 x float> %a, <4 x float> %a, | ||
| metadata !"round.downward", metadata !"fpexcept.strict") | ||
| ret void | ||
| } | ||
|
|
||
| ; CHECK: OpFMul %[[#]] %[[#]] %[[#]] | ||
| ; CHECK: OpFAdd %[[#]] %[[#]] %[[#]] | ||
| define spir_kernel void @test_v2f64(<2 x double> %a) { | ||
| entry: | ||
| %r = tail call <2 x double> @llvm.experimental.constrained.fmuladd.v2f64( | ||
| <2 x double> %a, <2 x double> %a, <2 x double> %a, | ||
| metadata !"round.tonearest", metadata !"fpexcept.strict") | ||
| ret void | ||
| } | ||
|
|
||
| declare float @llvm.experimental.constrained.fmuladd.f32(float, float, float, metadata, metadata) | ||
| declare double @llvm.experimental.constrained.fmuladd.f64(double, double, double, metadata, metadata) | ||
| declare <2 x float> @llvm.experimental.constrained.fmuladd.v2f32(<2 x float>, <2 x float>, <2 x float>, metadata, metadata) | ||
| declare <4 x float> @llvm.experimental.constrained.fmuladd.v4f32(<4 x float>, <4 x float>, <4 x float>, metadata, metadata) | ||
| declare <2 x double> @llvm.experimental.constrained.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>, metadata, metadata) |
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.
If the G_STRICT_FMAD is applied to a float or vector of floats, it will not be lowered. Is that what you want?
If you want it lowered all of the time, remove this line. I expect that is what you want based on earlier PRs.
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.
@s-perron I understood and I modified the legalizer info to directly lower the intrinsic as expected.