-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[LoopVectorizer][AArch64] Add support for partial reduce subtraction #123636
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
Changes from 8 commits
8569c7b
2690434
3d7caf1
132f245
ad49166
3757dd5
ada0d22
049bf68
842e5d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8800,6 +8800,10 @@ bool VPRecipeBuilder::getScaledReductions( | |
| return false; | ||
|
|
||
| using namespace llvm::PatternMatch; | ||
| // Use the side-effect of match to replace BinOp only if the pattern is | ||
| // matched, we don't care at this point whether it actually matched. | ||
| match(BinOp, m_Neg(m_BinOp(BinOp))); | ||
|
|
||
| Value *A, *B; | ||
| if (!match(BinOp->getOperand(0), m_ZExtOrSExt(m_Value(A))) || | ||
| !match(BinOp->getOperand(1), m_ZExtOrSExt(m_Value(B)))) | ||
|
|
@@ -8932,6 +8936,20 @@ VPRecipeBuilder::tryToCreatePartialReduction(Instruction *Reduction, | |
| std::swap(BinOp, Accumulator); | ||
|
|
||
| unsigned ReductionOpcode = Reduction->getOpcode(); | ||
| if (ReductionOpcode == Instruction::Sub) { | ||
| VPBasicBlock *ParentBlock = Builder.getInsertBlock(); | ||
| if (!ParentBlock) | ||
| return nullptr; | ||
|
||
|
|
||
| auto *const Zero = ConstantInt::get(Reduction->getType(), 0); | ||
| SmallVector<VPValue *, 2> Ops; | ||
| Ops.push_back(Plan.getOrAddLiveIn(Zero)); | ||
| Ops.push_back(BinOp); | ||
| BinOp = new VPWidenRecipe(*Reduction, make_range(Ops.begin(), Ops.end())); | ||
| ParentBlock->appendRecipe(BinOp->getDefiningRecipe()); | ||
| ReductionOpcode = Instruction::Add; | ||
| } | ||
|
|
||
| if (CM.blockNeedsPredicationForAnyReason(Reduction->getParent())) { | ||
| assert((ReductionOpcode == Instruction::Add || | ||
| ReductionOpcode == Instruction::Sub) && | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
I don't understand how this works. We've already bailed out above if
BinOpis not a BinaryOperator, which surely means that it cannot simultaneously be a unary operator, which is what m_Neg represents?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, I realise now that
m_Negis actually matching asub 0, %xoperation. Please ignore the noise!