[PATCH] D119924: [RISCV] [NFC] Add function isVectorConfigInstr to reduce redundant code.
Chenbing.Zheng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 16 01:30:59 PST 2022
Chenbing.Zheng created this revision.
Chenbing.Zheng added reviewers: craig.topper, frasercrmck, asb, benshi001.
Chenbing.Zheng added a project: LLVM.
Herald added subscribers: VincentWu, luke957, achieveartificialintelligence, vkmr, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya, tschuett.
Chenbing.Zheng requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead, eopXD, jacquesguan, MaskRay.
Put the same code into a function.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D119924
Files:
llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
Index: llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
+++ llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
@@ -447,6 +447,12 @@
INITIALIZE_PASS(RISCVInsertVSETVLI, DEBUG_TYPE, RISCV_INSERT_VSETVLI_NAME,
false, false)
+static bool isVectorConfigInstr(const MachineInstr &MI) {
+ return MI.getOpcode() == RISCV::PseudoVSETVLI ||
+ MI.getOpcode() == RISCV::PseudoVSETVLIX0 ||
+ MI.getOpcode() == RISCV::PseudoVSETIVLI;
+}
+
static MachineInstr *elideCopies(MachineInstr *MI,
const MachineRegisterInfo *MRI) {
while (true) {
@@ -655,9 +661,7 @@
Require.getAVLReg().isVirtual() && !CurInfo.hasSEWLMULRatioOnly() &&
CurInfo.hasCompatibleVTYPE(Require, /*Strict*/ false)) {
if (MachineInstr *DefMI = MRI->getVRegDef(Require.getAVLReg())) {
- if (DefMI->getOpcode() == RISCV::PseudoVSETVLI ||
- DefMI->getOpcode() == RISCV::PseudoVSETVLIX0 ||
- DefMI->getOpcode() == RISCV::PseudoVSETIVLI) {
+ if (isVectorConfigInstr(*DefMI)) {
VSETVLIInfo DefInfo = getInfoForVSETVLI(*DefMI);
if (DefInfo.hasSameAVL(CurInfo) && DefInfo.hasSameVTYPE(CurInfo))
return false;
@@ -870,9 +874,7 @@
BlockData &BBInfo = BlockInfo[MBB.getNumber()];
for (const MachineInstr &MI : MBB) {
// If this is an explicit VSETVLI or VSETIVLI, update our state.
- if (MI.getOpcode() == RISCV::PseudoVSETVLI ||
- MI.getOpcode() == RISCV::PseudoVSETVLIX0 ||
- MI.getOpcode() == RISCV::PseudoVSETIVLI) {
+ if (isVectorConfigInstr(MI)) {
HadVectorOp = true;
BBInfo.Change = getInfoForVSETVLI(MI);
continue;
@@ -983,9 +985,7 @@
// We need the PHI input to the be the output of a VSET(I)VLI.
MachineInstr *DefMI = MRI->getVRegDef(InReg);
- if (!DefMI || (DefMI->getOpcode() != RISCV::PseudoVSETVLI &&
- DefMI->getOpcode() != RISCV::PseudoVSETVLIX0 &&
- DefMI->getOpcode() != RISCV::PseudoVSETIVLI))
+ if (!DefMI || !isVectorConfigInstr(*DefMI))
return true;
// We found a VSET(I)VLI make sure it matches the output of the
@@ -1008,9 +1008,7 @@
for (MachineInstr &MI : MBB) {
// If this is an explicit VSETVLI or VSETIVLI, update our state.
- if (MI.getOpcode() == RISCV::PseudoVSETVLI ||
- MI.getOpcode() == RISCV::PseudoVSETVLIX0 ||
- MI.getOpcode() == RISCV::PseudoVSETIVLI) {
+ if (isVectorConfigInstr(MI)) {
// Conservatively, mark the VL and VTYPE as live.
assert(MI.getOperand(3).getReg() == RISCV::VL &&
MI.getOperand(4).getReg() == RISCV::VTYPE &&
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119924.409172.patch
Type: text/x-patch
Size: 2748 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220216/c59b6117/attachment-0001.bin>
More information about the llvm-commits
mailing list