-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[SLP] Fix PoisonValue in the argument VL of setOperand. #118949
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 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2a81c2c
[SLP] Pre-commit test.
HanKuanChen 4a407ef
[SLP] Fix PoisonValue in the argument VL of setOperand.
HanKuanChen bd9491e
apply comment
HanKuanChen e9b8dee
VL0 is already calculated by getSameOpcode
HanKuanChen 5b5fc90
[SLP] NFC. Replace TreeEntry::setOperandsInOrder with VLOperands. (#1…
HanKuanChen 517c32f
Merge remote-tracking branch 'origin/slp-refactor-vloperands' into sl…
HanKuanChen 142bd19
apply comment (do not pass VL0 to setOperand)
HanKuanChen 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 |
|---|---|---|
|
|
@@ -2403,14 +2403,13 @@ class BoUpSLP { | |
| } | ||
|
|
||
| /// Go through the instructions in VL and append their operands. | ||
| void appendOperandsOfVL(ArrayRef<Value *> VL) { | ||
| void appendOperandsOfVL(ArrayRef<Value *> VL, Instruction *VL0) { | ||
| assert(!VL.empty() && "Bad VL"); | ||
| assert((empty() || VL.size() == getNumLanes()) && | ||
| "Expected same number of lanes"); | ||
| // IntrinsicInst::isCommutative returns true if swapping the first "two" | ||
| // arguments to the intrinsic produces the same result. | ||
| constexpr unsigned IntrinsicNumOperands = 2; | ||
| auto *VL0 = cast<Instruction>(*find_if(VL, IsaPred<Instruction>)); | ||
| unsigned NumOperands = VL0->getNumOperands(); | ||
| ArgSize = isa<IntrinsicInst>(VL0) ? IntrinsicNumOperands : NumOperands; | ||
| OpsVec.resize(NumOperands); | ||
|
|
@@ -2542,13 +2541,11 @@ class BoUpSLP { | |
|
|
||
| public: | ||
| /// Initialize with all the operands of the instruction vector \p RootVL. | ||
| VLOperands(ArrayRef<Value *> RootVL, const BoUpSLP &R) | ||
| VLOperands(ArrayRef<Value *> RootVL, Instruction *VL0, const BoUpSLP &R) | ||
| : TLI(*R.TLI), DL(*R.DL), SE(*R.SE), R(R), | ||
| L(R.LI->getLoopFor( | ||
| (cast<Instruction>(*find_if(RootVL, IsaPred<Instruction>)) | ||
| ->getParent()))) { | ||
| L(R.LI->getLoopFor((VL0->getParent()))) { | ||
| // Append all the operands of RootVL. | ||
| appendOperandsOfVL(RootVL); | ||
| appendOperandsOfVL(RootVL, VL0); | ||
| } | ||
|
|
||
| /// \Returns a value vector with the operands across all lanes for the | ||
|
|
@@ -3338,14 +3335,13 @@ class BoUpSLP { | |
| copy(OpVL, Operands[OpIdx].begin()); | ||
| } | ||
|
|
||
| /// Set this bundle's operand from \p VL. | ||
| void setOperand(ArrayRef<Value *> VL, const BoUpSLP &R, | ||
| /// Set this bundle's operand from Scalars. | ||
| void setOperand(Instruction *VL0, const BoUpSLP &R, | ||
| bool RequireReorder = false) { | ||
| VLOperands Ops(VL, R); | ||
| VLOperands Ops(Scalars, VL0, R); | ||
|
||
| if (RequireReorder) | ||
| Ops.reorder(); | ||
| for (unsigned I : | ||
| seq<unsigned>(cast<Instruction>(VL[0])->getNumOperands())) | ||
| for (unsigned I : seq<unsigned>(VL0->getNumOperands())) | ||
| setOperand(I, Ops.getVL(I)); | ||
| } | ||
|
|
||
|
|
@@ -8446,7 +8442,7 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth, | |
| {}, CurrentOrder); | ||
| LLVM_DEBUG(dbgs() << "SLP: added inserts bundle.\n"); | ||
|
|
||
| TE->setOperand(VL, *this); | ||
| TE->setOperand(VL0, *this); | ||
| buildTree_rec(TE->getOperand(1), Depth + 1, {TE, 1}); | ||
| return; | ||
| } | ||
|
|
@@ -8484,7 +8480,7 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth, | |
| case TreeEntry::NeedToGather: | ||
| llvm_unreachable("Unexpected loads state."); | ||
| } | ||
| TE->setOperand(VL, *this); | ||
| TE->setOperand(VL0, *this); | ||
| if (State == TreeEntry::ScatterVectorize) | ||
| buildTree_rec(PointerOps, Depth + 1, {TE, 0}); | ||
| return; | ||
|
|
@@ -8524,7 +8520,7 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth, | |
| ReuseShuffleIndices); | ||
| LLVM_DEBUG(dbgs() << "SLP: added a vector of casts.\n"); | ||
|
|
||
| TE->setOperand(VL, *this); | ||
| TE->setOperand(VL0, *this); | ||
| for (unsigned I : seq<unsigned>(VL0->getNumOperands())) | ||
| buildTree_rec(TE->getOperand(I), Depth + 1, {TE, I}); | ||
| if (ShuffleOrOp == Instruction::Trunc) { | ||
|
|
@@ -8552,7 +8548,7 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth, | |
| LLVM_DEBUG(dbgs() << "SLP: added a vector of compares.\n"); | ||
|
|
||
| ValueList Left, Right; | ||
| VLOperands Ops(VL, *this); | ||
| VLOperands Ops(VL, VL0, *this); | ||
| if (cast<CmpInst>(VL0)->isCommutative()) { | ||
| // Commutative predicate - collect + sort operands of the instructions | ||
| // so that each side is more likely to have the same opcode. | ||
|
|
@@ -8621,7 +8617,8 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth, | |
| ReuseShuffleIndices); | ||
| LLVM_DEBUG(dbgs() << "SLP: added a vector of un/bin op.\n"); | ||
|
|
||
| TE->setOperand(VL, *this, isa<BinaryOperator>(VL0) && isCommutative(VL0)); | ||
| TE->setOperand(VL0, *this, | ||
| isa<BinaryOperator>(VL0) && isCommutative(VL0)); | ||
| for (unsigned I : seq<unsigned>(VL0->getNumOperands())) | ||
| buildTree_rec(TE->getOperand(I), Depth + 1, {TE, I}); | ||
| return; | ||
|
|
@@ -8687,7 +8684,7 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth, | |
| fixupOrderingIndices(CurrentOrder); | ||
| TreeEntry *TE = newTreeEntry(VL, Bundle /*vectorized*/, S, UserTreeIdx, | ||
| ReuseShuffleIndices, CurrentOrder); | ||
| TE->setOperand(VL, *this); | ||
| TE->setOperand(VL0, *this); | ||
| buildTree_rec(TE->getOperand(0), Depth + 1, {TE, 0}); | ||
| if (Consecutive) | ||
| LLVM_DEBUG(dbgs() << "SLP: added a vector of stores.\n"); | ||
|
|
@@ -8703,7 +8700,7 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth, | |
|
|
||
| TreeEntry *TE = newTreeEntry(VL, Bundle /*vectorized*/, S, UserTreeIdx, | ||
| ReuseShuffleIndices); | ||
| TE->setOperand(VL, *this, isCommutative(VL0)); | ||
| TE->setOperand(VL0, *this, isCommutative(VL0)); | ||
| for (unsigned I : seq<unsigned>(CI->arg_size())) { | ||
| // For scalar operands no need to create an entry since no need to | ||
| // vectorize it. | ||
|
|
@@ -8759,7 +8756,7 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth, | |
| return; | ||
| } | ||
|
|
||
| TE->setOperand(VL, *this, isa<BinaryOperator>(VL0) || CI); | ||
| TE->setOperand(VL0, *this, isa<BinaryOperator>(VL0) || CI); | ||
| for (unsigned I : seq<unsigned>(VL0->getNumOperands())) | ||
| buildTree_rec(TE->getOperand(I), Depth + 1, {TE, I}); | ||
| return; | ||
|
|
||
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,19 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | ||
| ; RUN: opt -passes=slp-vectorizer -S -slp-max-reg-size=1024 %s | FileCheck %s | ||
|
|
||
| define ptr @test() { | ||
| ; CHECK-LABEL: @test( | ||
| ; CHECK-NEXT: store <4 x double> <double poison, double 0.000000e+00, double 0.000000e+00, double 0.000000e+00>, ptr null, align 8 | ||
| ; CHECK-NEXT: ret ptr null | ||
| ; | ||
| store double poison, ptr null, align 8 | ||
| %1 = getelementptr i8, ptr null, i64 8 | ||
| %2 = fmul double 0.000000e+00, 0.000000e+00 | ||
| store double %2, ptr %1, align 8 | ||
| %3 = getelementptr i8, ptr null, i64 16 | ||
| %4 = fmul double 0.000000e+00, 0.000000e+00 | ||
| store double %4, ptr %3, align 8 | ||
| %5 = getelementptr i8, ptr null, i64 24 | ||
| store double %2, ptr %5, align 8 | ||
| ret ptr null | ||
| } |
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.
Make VL0 a member of the сlass, it is used in too many cases
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.
VL0 is only used by the constructor of VLOperands. I think you mean "Make VL0 a member of TreeEntry"?
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 we need to put VL0 into TreeEntry, I suggest we open the original PR (#113880 (comment)) and review there.
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.
Ah, no, no, need it.