Skip to content

Commit 20a3484

Browse files
authored
[RISCV] Add statistic support for VSETVL insertion pass (#78543)
This patch make vsetvl insertion pass could track the number of inserted/removed vsetvl instruction from `-stats` option.
1 parent 8649328 commit 20a3484

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include "RISCV.h"
2828
#include "RISCVSubtarget.h"
29+
#include "llvm/ADT/Statistic.h"
2930
#include "llvm/CodeGen/LiveIntervals.h"
3031
#include "llvm/CodeGen/MachineFunctionPass.h"
3132
#include <queue>
@@ -34,6 +35,9 @@ using namespace llvm;
3435
#define DEBUG_TYPE "riscv-insert-vsetvli"
3536
#define RISCV_INSERT_VSETVLI_NAME "RISC-V Insert VSETVLI pass"
3637

38+
STATISTIC(NumInsertedVSETVL, "Number of VSETVL inst inserted");
39+
STATISTIC(NumRemovedVSETVL, "Number of VSETVL inst removed");
40+
3741
static cl::opt<bool> DisableInsertVSETVLPHIOpt(
3842
"riscv-disable-insert-vsetvl-phi-opt", cl::init(false), cl::Hidden,
3943
cl::desc("Disable looking through phis when inserting vsetvlis."));
@@ -911,6 +915,7 @@ void RISCVInsertVSETVLI::insertVSETVLI(MachineBasicBlock &MBB,
911915
MachineBasicBlock::iterator InsertPt, DebugLoc DL,
912916
const VSETVLIInfo &Info, const VSETVLIInfo &PrevInfo) {
913917

918+
++NumInsertedVSETVL;
914919
if (PrevInfo.isValid() && !PrevInfo.isUnknown()) {
915920
// Use X0, X0 form if the AVL is the same and the SEW+LMUL gives the same
916921
// VLMAX.
@@ -1578,6 +1583,7 @@ void RISCVInsertVSETVLI::doLocalPostpass(MachineBasicBlock &MBB) {
15781583
Used = getDemanded(MI, MRI, ST);
15791584
}
15801585

1586+
NumRemovedVSETVL += ToDelete.size();
15811587
for (auto *MI : ToDelete)
15821588
MI->eraseFromParent();
15831589
}

0 commit comments

Comments
 (0)