[llvm] [RISCV] Add statistic support for VSETVL insertion pass (PR #78543)
Piyou Chen via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 17 21:53:27 PST 2024
https://github.com/BeMg created https://github.com/llvm/llvm-project/pull/78543
This patch make vsetvl insertion pass could track the number of inserted/removed vsetvl instruction from `-stats` option.
>From c6b01f23edd26c4011e6b90bc15bbf32941c56b9 Mon Sep 17 00:00:00 2001
From: Piyou Chen <piyou.chen at sifive.com>
Date: Wed, 17 Jan 2024 21:49:12 -0800
Subject: [PATCH] [RISCV] Add statistic info for VSETVL insertion pass
---
llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
index 3b15c71ef167c7..a14f9a28354737 100644
--- a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
@@ -26,6 +26,7 @@
#include "RISCV.h"
#include "RISCVSubtarget.h"
+#include "llvm/ADT/Statistic.h"
#include "llvm/CodeGen/LiveIntervals.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include <queue>
@@ -34,6 +35,9 @@ using namespace llvm;
#define DEBUG_TYPE "riscv-insert-vsetvli"
#define RISCV_INSERT_VSETVLI_NAME "RISC-V Insert VSETVLI pass"
+STATISTIC(NumInsertedVSETVL, "Number of VSETVL inst inserted");
+STATISTIC(NumRemovedVSETVL, "Number of VSETVL inst removed");
+
static cl::opt<bool> DisableInsertVSETVLPHIOpt(
"riscv-disable-insert-vsetvl-phi-opt", cl::init(false), cl::Hidden,
cl::desc("Disable looking through phis when inserting vsetvlis."));
@@ -911,6 +915,7 @@ void RISCVInsertVSETVLI::insertVSETVLI(MachineBasicBlock &MBB,
MachineBasicBlock::iterator InsertPt, DebugLoc DL,
const VSETVLIInfo &Info, const VSETVLIInfo &PrevInfo) {
+ ++NumInsertedVSETVL;
if (PrevInfo.isValid() && !PrevInfo.isUnknown()) {
// Use X0, X0 form if the AVL is the same and the SEW+LMUL gives the same
// VLMAX.
@@ -1578,6 +1583,7 @@ void RISCVInsertVSETVLI::doLocalPostpass(MachineBasicBlock &MBB) {
Used = getDemanded(MI, MRI, ST);
}
+ NumRemovedVSETVL += ToDelete.size();
for (auto *MI : ToDelete)
MI->eraseFromParent();
}
More information about the llvm-commits
mailing list