Skip to content

Commit 1e1ec91

Browse files
committed
[RISCV] Move PPBInfo exit check in needVSETVLIPHI. NFC
Compare the predecessor's exit after we've already checked that the PHI comes from a vsetvli. That way it's more obvious that Require has the same VL as PBBExit.
1 parent 771e4e8 commit 1e1ec91

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,11 +1337,7 @@ bool RISCVInsertVSETVLI::needVSETVLIPHI(const VSETVLIInfo &Require,
13371337
PHIOp += 2) {
13381338
Register InReg = PHI->getOperand(PHIOp).getReg();
13391339
MachineBasicBlock *PBB = PHI->getOperand(PHIOp + 1).getMBB();
1340-
const BlockData &PBBInfo = BlockInfo[PBB->getNumber()];
1341-
// If the exit from the predecessor has the VTYPE we are looking for
1342-
// we might be able to avoid a VSETVLI.
1343-
if (PBBInfo.Exit.isUnknown() || !PBBInfo.Exit.hasSameVTYPE(Require))
1344-
return true;
1340+
const VSETVLIInfo &PBBExit = BlockInfo[PBB->getNumber()].Exit;
13451341

13461342
// We need the PHI input to the be the output of a VSET(I)VLI.
13471343
MachineInstr *DefMI = MRI->getVRegDef(InReg);
@@ -1351,7 +1347,13 @@ bool RISCVInsertVSETVLI::needVSETVLIPHI(const VSETVLIInfo &Require,
13511347
// We found a VSET(I)VLI make sure it matches the output of the
13521348
// predecessor block.
13531349
VSETVLIInfo DefInfo = getInfoForVSETVLI(*DefMI);
1354-
if (DefInfo != PBBInfo.Exit)
1350+
if (DefInfo != PBBExit)
1351+
return true;
1352+
1353+
// Require has the same VL as PBBExit, so if the exit from the
1354+
// predecessor has the VTYPE we are looking for we might be able
1355+
// to avoid a VSETVLI.
1356+
if (PBBExit.isUnknown() || !PBBExit.hasSameVTYPE(Require))
13551357
return true;
13561358
}
13571359

0 commit comments

Comments
 (0)