-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[RISCV] Sink vp.splat operands of VP intrinsic. #133245
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 2 commits
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 |
|---|---|---|
|
|
@@ -2838,41 +2838,46 @@ bool RISCVTTIImpl::isProfitableToSinkOperands( | |
| if (!ST->sinkSplatOperands()) | ||
| return false; | ||
|
|
||
| for (auto OpIdx : enumerate(I->operands())) { | ||
| if (!canSplatOperand(I, OpIdx.index())) | ||
| continue; | ||
|
|
||
| Instruction *Op = dyn_cast<Instruction>(OpIdx.value().get()); | ||
| for (auto &U : I->operands()) { | ||
| auto *Op = dyn_cast<Instruction>(U.get()); | ||
| // Make sure we are not already sinking this operand | ||
| if (!Op || any_of(Ops, [&](Use *U) { return U->get() == Op; })) | ||
| continue; | ||
|
|
||
| // We are looking for a splat that can be sunk. | ||
| if (!match(Op, m_Shuffle(m_InsertElt(m_Undef(), m_Value(), m_ZeroInt()), | ||
| // We are looking for a splat/vp.splat that can be sunk. | ||
| bool IsVPSplat = match(Op, m_Intrinsic<Intrinsic::experimental_vp_splat>( | ||
| m_Value(), m_Value(), m_Value())); | ||
| if (!IsVPSplat && | ||
| !match(Op, m_Shuffle(m_InsertElt(m_Undef(), m_Value(), m_ZeroInt()), | ||
| m_Undef(), m_ZeroMask()))) | ||
| continue; | ||
NexMing marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Don't sink i1 splats. | ||
| if (cast<VectorType>(Op->getType())->getElementType()->isIntegerTy(1)) | ||
| continue; | ||
|
|
||
| // All uses of the shuffle should be sunk to avoid duplicating it across gpr | ||
| // and vector registers | ||
| for (Use &U : Op->uses()) { | ||
| Instruction *Insn = cast<Instruction>(U.getUser()); | ||
| if (!canSplatOperand(Insn, U.getOperandNo())) | ||
| return false; | ||
| } | ||
| // All uses of the splat/vp.splat should be sunk to avoid duplicating it | ||
| // across gpr and vector registers | ||
| if (any_of(Op->uses(), [this](Use &U) { | ||
| return !canSplatOperand(cast<Instruction>(U.getUser()), | ||
| U.getOperandNo()); | ||
| })) | ||
| continue; | ||
|
||
|
|
||
| Use *InsertEltUse = &Op->getOperandUse(0); | ||
| // Sink any fpexts since they might be used in a widening fp pattern. | ||
| auto *InsertElt = cast<InsertElementInst>(InsertEltUse); | ||
| if (isa<FPExtInst>(InsertElt->getOperand(1))) | ||
| Ops.push_back(&InsertElt->getOperandUse(1)); | ||
| Ops.push_back(InsertEltUse); | ||
| Ops.push_back(&OpIdx.value()); | ||
| if (IsVPSplat) { | ||
| if (isa<FPExtInst>(Op->getOperand(0))) | ||
| Ops.push_back(&Op->getOperandUse(0)); | ||
| } else { | ||
| Use *InsertEltUse = &Op->getOperandUse(0); | ||
| auto *InsertElt = cast<InsertElementInst>(InsertEltUse); | ||
| if (isa<FPExtInst>(InsertElt->getOperand(1))) | ||
| Ops.push_back(&InsertElt->getOperandUse(1)); | ||
| Ops.push_back(InsertEltUse); | ||
| } | ||
| Ops.push_back(&U); | ||
| } | ||
| return true; | ||
| return !Ops.empty(); | ||
| } | ||
|
|
||
| RISCVTTIImpl::TTI::MemCmpExpansionOptions | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.