-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[Arch64][SVE] Lower svrev_* to llvm.vector.reverse and fold svrev(svrev(x)) -> x #116422
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
jf-botto
wants to merge
2
commits into
llvm:main
Choose a base branch
from
jf-botto:110444
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
2 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2368,6 +2368,7 @@ static std::optional<Instruction *> instCombineSVEUzp1(InstCombiner &IC, | |
|
|
||
| // uzp1(to_svbool(A), to_svbool(B)) --> <A, B> | ||
| // uzp1(from_svbool(to_svbool(A)), from_svbool(to_svbool(B))) --> <A, B> | ||
|
|
||
| if ((match(II.getArgOperand(0), | ||
| m_Intrinsic<FromSVB>(m_Intrinsic<ToSVB>(m_Value(A)))) && | ||
| match(II.getArgOperand(1), | ||
|
|
@@ -2674,6 +2675,52 @@ static std::optional<Instruction *> instCombinePTrue(InstCombiner &IC, | |
| return std::nullopt; | ||
| } | ||
|
|
||
| static std::optional<Instruction *> instCombineSVERev(InstCombiner &IC, | ||
| IntrinsicInst &II) { | ||
| // rev(rev(x)) -> x | ||
| switch (II.getIntrinsicID()) { | ||
| default: | ||
| return std::nullopt; | ||
|
|
||
| case Intrinsic::aarch64_sve_rev: | ||
| case Intrinsic::aarch64_sve_rev_b16: | ||
| case Intrinsic::aarch64_sve_rev_b32: | ||
| case Intrinsic::aarch64_sve_rev_b64: { | ||
| Value *InnerArg = II.getArgOperand(0); | ||
| IntrinsicInst *InnerRev = dyn_cast<IntrinsicInst>(InnerArg); | ||
| // Fold rev(rev(x)) -> x, if intrinsic IDs match and InnerRev has one use | ||
| if (InnerRev && InnerRev->getIntrinsicID() == II.getIntrinsicID() && | ||
| InnerRev->hasOneUse()) | ||
| return IC.replaceInstUsesWith(II, InnerRev->getArgOperand(0)); | ||
|
|
||
| return std::nullopt; | ||
| } | ||
|
|
||
| case Intrinsic::aarch64_sve_revb: | ||
| case Intrinsic::aarch64_sve_revd: | ||
| case Intrinsic::aarch64_sve_revh: | ||
| case Intrinsic::aarch64_sve_revw: { | ||
| Value *InnerArg = II.getArgOperand(2); | ||
| IntrinsicInst *InnerRev = dyn_cast<IntrinsicInst>(InnerArg); | ||
|
|
||
| // Early exit if InnerRev != outerId and doesn't only have one use | ||
| if (!InnerRev || InnerRev->getIntrinsicID() != II.getIntrinsicID() || | ||
| !InnerRev->hasOneUse()) | ||
| return std::nullopt; | ||
|
|
||
| Value *OuterPred = II.getArgOperand(0); | ||
| Value *OuterPassThru = II.getArgOperand(1); | ||
| Value *InnerPred = InnerRev->getArgOperand(0); | ||
| Value *InnerPassThru = InnerRev->getArgOperand(1); | ||
|
Comment on lines
+2711
to
+2714
Collaborator
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. These variables are all unused. |
||
|
|
||
| // Fold rev(rev(x)) -> x, if predicates and pass-thrus match | ||
| return IC.replaceInstUsesWith(II, InnerRev->getArgOperand(2)); | ||
|
|
||
| return std::nullopt; | ||
|
Comment on lines
+2717
to
+2719
Collaborator
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. a return after a return? |
||
| } | ||
| } | ||
| } | ||
|
|
||
| std::optional<Instruction *> | ||
| AArch64TTIImpl::instCombineIntrinsic(InstCombiner &IC, | ||
| IntrinsicInst &II) const { | ||
|
|
@@ -2773,6 +2820,15 @@ AArch64TTIImpl::instCombineIntrinsic(InstCombiner &IC, | |
| return instCombineSVEInsr(IC, II); | ||
| case Intrinsic::aarch64_sve_ptrue: | ||
| return instCombinePTrue(IC, II); | ||
| case Intrinsic::aarch64_sve_rev: | ||
| case Intrinsic::aarch64_sve_rev_b16: | ||
| case Intrinsic::aarch64_sve_rev_b32: | ||
| case Intrinsic::aarch64_sve_rev_b64: | ||
| case Intrinsic::aarch64_sve_revb: | ||
| case Intrinsic::aarch64_sve_revd: | ||
| case Intrinsic::aarch64_sve_revh: | ||
| case Intrinsic::aarch64_sve_revw: | ||
| return instCombineSVERev(IC, II); | ||
| } | ||
|
|
||
| return std::nullopt; | ||
|
|
||
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.
This is still missing checks for the governing predicate.