-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[Scalarizer] Fix to only scalarize if intrinsic was marked as isTriviallyScalarizable #113625
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1084,6 +1084,17 @@ bool ScalarizerVisitor::visitExtractValueInst(ExtractValueInst &EVI) { | |
ValueVector Res; | ||
if (!isStructOfMatchingFixedVectors(OpTy)) | ||
return false; | ||
if (CallInst *CI = dyn_cast<CallInst>(Op)) { | ||
Function *F = CI->getCalledFunction(); | ||
if (!F) | ||
return false; | ||
Intrinsic::ID ID = F->getIntrinsicID(); | ||
if (ID == Intrinsic::not_intrinsic || !isTriviallyScalarizable(ID)) | ||
return false; | ||
// Note: Fall through means Operand is a`CallInst` and it is defined in | ||
// `isTriviallyScalarizable`. | ||
} else | ||
return false; | ||
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. Will you ever see non-intrinsic calls here? If so, please add a test case for that. Also nit: the "else" clause should have braces if the "if" clause has braces. |
||
Type *VecType = cast<FixedVectorType>(OpTy->getContainedType(0)); | ||
std::optional<VectorSplit> VS = getVectorSplit(VecType); | ||
if (!VS) | ||
|
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,16 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt %s -passes='function(scalarizer)' -S | FileCheck %s | ||
|
||
; Test to make sure that struct return intrinsics that are not `isTriviallyScalarizable` do not get scalarized. | ||
|
||
define <3 x i32> @test_(<3 x i32> %a, <3 x i32> %b) { | ||
; CHECK-LABEL: define <3 x i32> @test_( | ||
; CHECK-SAME: <3 x i32> [[A:%.*]], <3 x i32> [[B:%.*]]) { | ||
; CHECK-NEXT: [[R:%.*]] = call { <3 x i32>, <3 x i1> } @llvm.uadd.with.overflow.v3i32(<3 x i32> [[B]], <3 x i32> [[B]]) | ||
; CHECK-NEXT: [[EL:%.*]] = extractvalue { <3 x i32>, <3 x i1> } [[R]], 0 | ||
; CHECK-NEXT: ret <3 x i32> [[EL]] | ||
; | ||
%r = call { <3 x i32>, <3 x i1> } @llvm.uadd.with.overflow.v3i32(<3 x i32> %b, <3 x i32> %b) | ||
%el = extractvalue { <3 x i32>, <3 x i1> } %r, 0 | ||
ret <3 x i32> %el | ||
} |
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.
Can you just handle
IntrinsicInst
here, instead of manually checking for a known callee and looking up the id?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.
Still need to lookup the id, but yes this could be
IntrinsicInst
.