-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[LegacyPM][DirectX] Add legacy scalarizer back for use in the DirectX backend #107427
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,39 @@ | ||
; RUN: opt -S -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library %s | FileCheck %s | ||
; RUN: opt -S -scalarizer -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library %s | FileCheck %s | ||
|
||
; Make sure dxil operation function calls for acos are generated for float and half. | ||
|
||
define noundef float @tan_float(float noundef %a) { | ||
define noundef float @acos_float(float noundef %a) { | ||
entry: | ||
; CHECK:call float @dx.op.unary.f32(i32 15, float %{{.*}}) | ||
%elt.acos = call float @llvm.acos.f32(float %a) | ||
ret float %elt.acos | ||
} | ||
|
||
define noundef half @tan_half(half noundef %a) { | ||
define noundef half @acos_half(half noundef %a) { | ||
entry: | ||
; CHECK:call half @dx.op.unary.f16(i32 15, half %{{.*}}) | ||
%elt.acos = call half @llvm.acos.f16(half %a) | ||
ret half %elt.acos | ||
} | ||
|
||
define noundef <4 x float> @acos_float4(<4 x float> noundef %a) { | ||
entry: | ||
; CHECK: [[ee0:%.*]] = extractelement <4 x float> %a, i64 0 | ||
; CHECK: [[ie0:%.*]] = call float @dx.op.unary.f32(i32 15, float [[ee0]]) | ||
; CHECK: [[ee1:%.*]] = extractelement <4 x float> %a, i64 1 | ||
; CHECK: [[ie1:%.*]] = call float @dx.op.unary.f32(i32 15, float [[ee1]]) | ||
; CHECK: [[ee2:%.*]] = extractelement <4 x float> %a, i64 2 | ||
; CHECK: [[ie2:%.*]] = call float @dx.op.unary.f32(i32 15, float [[ee2]]) | ||
; CHECK: [[ee3:%.*]] = extractelement <4 x float> %a, i64 3 | ||
; CHECK: [[ie3:%.*]] = call float @dx.op.unary.f32(i32 15, float [[ee3]]) | ||
; CHECK: insertelement <4 x float> poison, float [[ie0]], i64 0 | ||
; CHECK: insertelement <4 x float> %{{.*}}, float [[ie1]], i64 1 | ||
; CHECK: insertelement <4 x float> %{{.*}}, float [[ie2]], i64 2 | ||
; CHECK: insertelement <4 x float> %{{.*}}, float [[ie3]], i64 3 | ||
%2 = call <4 x float> @llvm.acos.v4f32(<4 x float> %a) | ||
ret <4 x float> %2 | ||
} | ||
|
||
declare half @llvm.acos.f16(half) | ||
declare float @llvm.acos.f32(float) | ||
declare <4 x float> @llvm.acos.v4f32(<4 x float>) |
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 |
---|---|---|
@@ -1,20 +1,39 @@ | ||
; RUN: opt -S -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library %s | FileCheck %s | ||
; RUN: opt -S -scalarizer -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library %s | FileCheck %s | ||
|
||
; Make sure dxil operation function calls for asin are generated for float and half. | ||
|
||
define noundef float @tan_float(float noundef %a) { | ||
define noundef float @asin_float(float noundef %a) { | ||
entry: | ||
; CHECK:call float @dx.op.unary.f32(i32 16, float %{{.*}}) | ||
%elt.asin = call float @llvm.asin.f32(float %a) | ||
ret float %elt.asin | ||
} | ||
|
||
define noundef half @tan_half(half noundef %a) { | ||
define noundef half @asin_half(half noundef %a) { | ||
entry: | ||
; CHECK:call half @dx.op.unary.f16(i32 16, half %{{.*}}) | ||
%elt.asin = call half @llvm.asin.f16(half %a) | ||
ret half %elt.asin | ||
} | ||
|
||
define noundef <4 x float> @asin_float4(<4 x float> noundef %a) { | ||
entry: | ||
; CHECK: [[ee0:%.*]] = extractelement <4 x float> %a, i64 0 | ||
; CHECK: [[ie0:%.*]] = call float @dx.op.unary.f32(i32 16, float [[ee0]]) | ||
; CHECK: [[ee1:%.*]] = extractelement <4 x float> %a, i64 1 | ||
; CHECK: [[ie1:%.*]] = call float @dx.op.unary.f32(i32 16, float [[ee1]]) | ||
; CHECK: [[ee2:%.*]] = extractelement <4 x float> %a, i64 2 | ||
; CHECK: [[ie2:%.*]] = call float @dx.op.unary.f32(i32 16, float [[ee2]]) | ||
; CHECK: [[ee3:%.*]] = extractelement <4 x float> %a, i64 3 | ||
; CHECK: [[ie3:%.*]] = call float @dx.op.unary.f32(i32 16, float [[ee3]]) | ||
; CHECK: insertelement <4 x float> poison, float [[ie0]], i64 0 | ||
; CHECK: insertelement <4 x float> %{{.*}}, float [[ie1]], i64 1 | ||
; CHECK: insertelement <4 x float> %{{.*}}, float [[ie2]], i64 2 | ||
; CHECK: insertelement <4 x float> %{{.*}}, float [[ie3]], i64 3 | ||
%2 = call <4 x float> @llvm.asin.v4f32(<4 x float> %a) | ||
ret <4 x float> %2 | ||
} | ||
|
||
declare half @llvm.asin.f16(half) | ||
declare float @llvm.asin.f32(float) | ||
declare <4 x float> @llvm.asin.v4f32(<4 x float>) |
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 |
---|---|---|
@@ -1,20 +1,39 @@ | ||
; RUN: opt -S -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library %s | FileCheck %s | ||
; RUN: opt -S -scalarizer -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library %s | FileCheck %s | ||
|
||
; Make sure dxil operation function calls for atan are generated for float and half. | ||
|
||
define noundef float @tan_float(float noundef %a) { | ||
define noundef float @atan_float(float noundef %a) { | ||
entry: | ||
; CHECK:call float @dx.op.unary.f32(i32 17, float %{{.*}}) | ||
%elt.atan = call float @llvm.atan.f32(float %a) | ||
ret float %elt.atan | ||
} | ||
|
||
define noundef half @tan_half(half noundef %a) { | ||
define noundef half @atan_half(half noundef %a) { | ||
entry: | ||
; CHECK:call half @dx.op.unary.f16(i32 17, half %{{.*}}) | ||
%elt.atan = call half @llvm.atan.f16(half %a) | ||
ret half %elt.atan | ||
} | ||
|
||
define noundef <4 x float> @atan_float4(<4 x float> noundef %a) { | ||
entry: | ||
; CHECK: [[ee0:%.*]] = extractelement <4 x float> %a, i64 0 | ||
; CHECK: [[ie0:%.*]] = call float @dx.op.unary.f32(i32 17, float [[ee0]]) | ||
; CHECK: [[ee1:%.*]] = extractelement <4 x float> %a, i64 1 | ||
; CHECK: [[ie1:%.*]] = call float @dx.op.unary.f32(i32 17, float [[ee1]]) | ||
; CHECK: [[ee2:%.*]] = extractelement <4 x float> %a, i64 2 | ||
; CHECK: [[ie2:%.*]] = call float @dx.op.unary.f32(i32 17, float [[ee2]]) | ||
; CHECK: [[ee3:%.*]] = extractelement <4 x float> %a, i64 3 | ||
; CHECK: [[ie3:%.*]] = call float @dx.op.unary.f32(i32 17, float [[ee3]]) | ||
; CHECK: insertelement <4 x float> poison, float [[ie0]], i64 0 | ||
; CHECK: insertelement <4 x float> %{{.*}}, float [[ie1]], i64 1 | ||
; CHECK: insertelement <4 x float> %{{.*}}, float [[ie2]], i64 2 | ||
; CHECK: insertelement <4 x float> %{{.*}}, float [[ie3]], i64 3 | ||
%2 = call <4 x float> @llvm.atan.v4f32(<4 x float> %a) | ||
ret <4 x float> %2 | ||
} | ||
|
||
declare half @llvm.atan.f16(half) | ||
declare float @llvm.atan.f32(float) | ||
declare <4 x float> @llvm.atan.v4f32(<4 x float>) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,39 @@ | ||
; RUN: opt -S -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library %s | FileCheck %s | ||
; RUN: opt -S -scalarizer -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library %s | FileCheck %s | ||
|
||
; Make sure dxil operation function calls for cosh are generated for float and half. | ||
|
||
define noundef float @tan_float(float noundef %a) { | ||
define noundef float @cosh_float(float noundef %a) { | ||
entry: | ||
; CHECK:call float @dx.op.unary.f32(i32 18, float %{{.*}}) | ||
%elt.cosh = call float @llvm.cosh.f32(float %a) | ||
ret float %elt.cosh | ||
} | ||
|
||
define noundef half @tan_half(half noundef %a) { | ||
define noundef half @cosh_half(half noundef %a) { | ||
entry: | ||
; CHECK:call half @dx.op.unary.f16(i32 18, half %{{.*}}) | ||
%elt.cosh = call half @llvm.cosh.f16(half %a) | ||
ret half %elt.cosh | ||
} | ||
|
||
define noundef <4 x float> @cosh_float4(<4 x float> noundef %a) #0 { | ||
entry: | ||
; CHECK: [[ee0:%.*]] = extractelement <4 x float> %a, i64 0 | ||
; CHECK: [[ie0:%.*]] = call float @dx.op.unary.f32(i32 18, float [[ee0]]) | ||
; CHECK: [[ee1:%.*]] = extractelement <4 x float> %a, i64 1 | ||
; CHECK: [[ie1:%.*]] = call float @dx.op.unary.f32(i32 18, float [[ee1]]) | ||
; CHECK: [[ee2:%.*]] = extractelement <4 x float> %a, i64 2 | ||
; CHECK: [[ie2:%.*]] = call float @dx.op.unary.f32(i32 18, float [[ee2]]) | ||
; CHECK: [[ee3:%.*]] = extractelement <4 x float> %a, i64 3 | ||
; CHECK: [[ie3:%.*]] = call float @dx.op.unary.f32(i32 18, float [[ee3]]) | ||
; CHECK: insertelement <4 x float> poison, float [[ie0]], i64 0 | ||
; CHECK: insertelement <4 x float> %{{.*}}, float [[ie1]], i64 1 | ||
; CHECK: insertelement <4 x float> %{{.*}}, float [[ie2]], i64 2 | ||
; CHECK: insertelement <4 x float> %{{.*}}, float [[ie3]], i64 3 | ||
%2 = call <4 x float> @llvm.cosh.v4f32(<4 x float> %a) | ||
ret <4 x float> %2 | ||
} | ||
|
||
declare half @llvm.cosh.f16(half) | ||
declare float @llvm.cosh.f32(float) | ||
declare <4 x float> @llvm.cosh.v4f32(<4 x float>) |
Oops, something went wrong.
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.
@boomanaiden154 and @nikic Since you removed and approved the removal of the legacy pass in this commit: 2470857
I wanted to make sure you were ok with our reasons for bringing it back for the DIrectX backend?
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.
It's ok to bring the pass back for backend use. Just to confirm, the pass is a legalization requirement and injecting it via a pass builder callback into the middle-end pipeline is not an option?
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.
Yes its a legalization requirement. It handles extraneous inserts element cleanup as-well that we need for the DXIL to be correct. So it makes the most sense for us to do this in the backend.
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.
It seems reasonable enough to me. There are still quite a few (late) middle-end passes that support both the NewPM and the legacyPM due to being needed by backends. The main reason for removal was that no one was using the
ScalarizerLegacyPass
and thus there was no test coverage.If someone is using it, it's reasonable enough to keep 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.
@nikic or @boomanaiden154 would you be willing to approve this PR.