Skip to content

Commit ec5d17b

Browse files
committed
[RISCV] Explicitly check for passthru in doPeepholeMaskedRVV. NFC
We were previously checking a combination of the vector policy op and the opcode to determine if we needed to skip copying the passthru from a masked pseudo to an unmasked pseudo. However we can just do this by checking RISCVII::isFirstDefTiedToFirstUse, which is a proxy for whether or not a pseudo has a passthru operand. This should hopefully remove the need for the changes in #123106
1 parent 98dbce3 commit ec5d17b

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3791,15 +3791,6 @@ static bool isImplicitDef(SDValue V) {
37913791
return V.getMachineOpcode() == TargetOpcode::IMPLICIT_DEF;
37923792
}
37933793

3794-
static bool hasGPROut(unsigned Opc) {
3795-
switch (RISCV::getRVVMCOpcode(Opc)) {
3796-
case RISCV::VCPOP_M:
3797-
case RISCV::VFIRST_M:
3798-
return true;
3799-
}
3800-
return false;
3801-
}
3802-
38033794
// Optimize masked RVV pseudo instructions with a known all-ones mask to their
38043795
// corresponding "unmasked" pseudo versions. The mask we're interested in will
38053796
// take the form of a V0 physical register operand, with a glued
@@ -3818,19 +3809,22 @@ bool RISCVDAGToDAGISel::doPeepholeMaskedRVV(MachineSDNode *N) {
38183809
// everything else. See the comment on RISCVMaskedPseudo for details.
38193810
const unsigned Opc = I->UnmaskedPseudo;
38203811
const MCInstrDesc &MCID = TII->get(Opc);
3821-
const bool UseTUPseudo = RISCVII::hasVecPolicyOp(MCID.TSFlags);
3822-
#ifndef NDEBUG
3812+
const bool HasPassthru = RISCVII::isFirstDefTiedToFirstUse(MCID);
3813+
38233814
const MCInstrDesc &MaskedMCID = TII->get(N->getMachineOpcode());
3815+
const bool MaskedHasPassthru = RISCVII::isFirstDefTiedToFirstUse(MaskedMCID);
3816+
38243817
assert(RISCVII::hasVecPolicyOp(MaskedMCID.TSFlags) ==
38253818
RISCVII::hasVecPolicyOp(MCID.TSFlags) &&
38263819
"Masked and unmasked pseudos are inconsistent");
3827-
const bool HasTiedDest = RISCVII::isFirstDefTiedToFirstUse(MCID);
3828-
assert(UseTUPseudo == HasTiedDest && "Unexpected pseudo structure");
3829-
#endif
3820+
assert(RISCVII::hasVecPolicyOp(MCID.TSFlags) == HasPassthru &&
3821+
"Unexpected pseudo structure");
3822+
assert(!(HasPassthru && !MaskedHasPassthru) &&
3823+
"Unmasked pseudo has passthru but masked pseudo doesn't?");
38303824

38313825
SmallVector<SDValue, 8> Ops;
3832-
// Skip the passthru operand at index 0 if !UseTUPseudo and no GPR out.
3833-
bool ShouldSkip = !UseTUPseudo && !hasGPROut(Opc);
3826+
// Skip the passthru operand at index 0 if the unmasked don't have one.
3827+
bool ShouldSkip = !HasPassthru && MaskedHasPassthru;
38343828
for (unsigned I = ShouldSkip, E = N->getNumOperands(); I != E; I++) {
38353829
// Skip the mask, and the Glue.
38363830
SDValue Op = N->getOperand(I);

0 commit comments

Comments
 (0)