-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[InstCombine] Handle scalable splats of constants in getMinimumFPType #132960
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
lukel97
merged 4 commits into
llvm:main
from
lukel97:instcombine/getMinimumFPType-scalable-splat
Mar 27, 2025
Merged
Changes from 2 commits
Commits
Show all changes
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,16 @@ define <vscale x 2 x float> @shrink_splat_scalable_extend(<vscale x 2 x float> % | |
%5 = fptrunc <vscale x 2 x double> %4 to <vscale x 2 x float> | ||
ret <vscale x 2 x float> %5 | ||
} | ||
|
||
define <vscale x 2 x float> @shrink_splat_scalable_extend_rhs_constexpr(<vscale x 2 x float> %a) { | ||
; CHECK-LABEL: define <vscale x 2 x float> @shrink_splat_scalable_extend_rhs_constexpr( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be good to have a fixed-width variant of this too, if there isn't one already? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added to fpextend.ll in d26e672 |
||
; CHECK-SAME: <vscale x 2 x float> [[A:%.*]]) { | ||
; CHECK-NEXT: [[TMP1:%.*]] = fptrunc <vscale x 2 x double> splat (double -1.000000e+00) to <vscale x 2 x float> | ||
; CHECK-NEXT: [[TMP3:%.*]] = fadd <vscale x 2 x float> [[A]], [[TMP1]] | ||
; CHECK-NEXT: ret <vscale x 2 x float> [[TMP3]] | ||
; | ||
%2 = fpext <vscale x 2 x float> %a to <vscale x 2 x double> | ||
%4 = fadd <vscale x 2 x double> %2, splat (double -1.000000e+00) | ||
%5 = fptrunc <vscale x 2 x double> %4 to <vscale x 2 x float> | ||
ret <vscale x 2 x float> %5 | ||
} |
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.
In
InstCombinerImpl::visitCallInst
there is a similar example of using splats:and I wondered if it was worth doing the same here. Perhaps I'm wrong, but I thought splats aren't restricted to scalable vectors I think and would apply to fixed-width too? For example,
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.
Fixed-width vectors are handled by
shrinkFPConstantVector
below.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.
Yeah, shrinkFPConstantVector will handle splatted and non-splatted fixed vectors too.
But I think it should be NFC if we also handle fixed splats here, I guess it would act as a sort of fast path to prevent having to check shrinkFPConstant on each element? I've added it to this PR but let me know if you want to leave it out to keep it closer to the original
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.
Thanks for this. I personally think it looks neater to handle all splats in one place.