[PATCH] D152961: [RISCV] Refactor vecPolicyOp skip logic in doPeepholeMaskedRVV. NFC
Luke Lau via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 14 14:15:43 PDT 2023
luke created this revision.
luke added reviewers: reames, craig.topper, frasercrmck, arcbbb.
Herald added subscribers: jobnoorman, asb, pmatos, VincentWu, vkmr, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya, arichardson.
Herald added a project: All.
luke requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead, eopXD, MaskRay.
Herald added a project: LLVM.
We can just explicitly check if the new unmasked pseudo takes a policy
op, rather than implicitly relying on I->UnmaskedTUPseudo ==
I->UnmaskedPseudo. Split out from another patch to make the diff more
readable.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D152961
Files:
llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
Index: llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
+++ llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
@@ -3183,13 +3183,15 @@
std::optional<unsigned> TailPolicyOpIdx;
const MCInstrDesc &MaskedMCID = TII->get(N->getMachineOpcode());
+ if (RISCVII::hasVecPolicyOp(MaskedMCID.TSFlags))
+ TailPolicyOpIdx = getVecPolicyOpIdx(N, MaskedMCID);
+
bool UseTUPseudo = false;
if (RISCVII::hasVecPolicyOp(MaskedMCID.TSFlags)) {
// Some operations are their own TU.
if (I->UnmaskedTUPseudo == I->UnmaskedPseudo) {
UseTUPseudo = true;
} else {
- TailPolicyOpIdx = getVecPolicyOpIdx(N, MaskedMCID);
if (!(N->getConstantOperandVal(*TailPolicyOpIdx) &
RISCVII::TAIL_AGNOSTIC)) {
// Keep the true-masked instruction when there is no unmasked TU
@@ -3202,11 +3204,11 @@
}
unsigned Opc = UseTUPseudo ? I->UnmaskedTUPseudo : I->UnmaskedPseudo;
+ const MCInstrDesc &MCID = TII->get(Opc);
// If this instruction is tail agnostic, the unmasked instruction should not
// have a tied destination.
#ifndef NDEBUG
- const MCInstrDesc &MCID = TII->get(Opc);
bool HasTiedDest = RISCVII::isFirstDefTiedToFirstUse(MCID);
assert((UseTUPseudo == HasTiedDest) && "Unexpected pseudo to transform to");
#endif
@@ -3214,9 +3216,11 @@
SmallVector<SDValue, 8> Ops;
// Skip the merge operand at index 0 if !UseTUPseudo.
for (unsigned I = !UseTUPseudo, E = N->getNumOperands(); I != E; I++) {
- // Skip the mask, the policy, and the Glue.
+ // Skip the mask, the policy (if the unmasked doesn't have a policy op), and
+ // the Glue.
SDValue Op = N->getOperand(I);
- if (I == MaskOpIdx || I == TailPolicyOpIdx ||
+ if (I == MaskOpIdx ||
+ (I == TailPolicyOpIdx && !RISCVII::hasVecPolicyOp(MCID.TSFlags)) ||
Op.getValueType() == MVT::Glue)
continue;
Ops.push_back(Op);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152961.531511.patch
Type: text/x-patch
Size: 1995 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230614/9d6dbe97/attachment.bin>
More information about the llvm-commits
mailing list