diff --git a/llvm/lib/Target/RISCV/CMakeLists.txt b/llvm/lib/Target/RISCV/CMakeLists.txt --- a/llvm/lib/Target/RISCV/CMakeLists.txt +++ b/llvm/lib/Target/RISCV/CMakeLists.txt @@ -21,10 +21,10 @@ add_llvm_target(RISCVCodeGen RISCVAsmPrinter.cpp RISCVCallLowering.cpp - RISCVCleanupVSETVLI.cpp RISCVExpandAtomicPseudoInsts.cpp RISCVExpandPseudoInsts.cpp RISCVFrameLowering.cpp + RISCVInsertVSETVLI.cpp RISCVInstrInfo.cpp RISCVInstructionSelector.cpp RISCVISelDAGToDAG.cpp diff --git a/llvm/lib/Target/RISCV/RISCV.h b/llvm/lib/Target/RISCV/RISCV.h --- a/llvm/lib/Target/RISCV/RISCV.h +++ b/llvm/lib/Target/RISCV/RISCV.h @@ -46,8 +46,8 @@ FunctionPass *createRISCVExpandAtomicPseudoPass(); void initializeRISCVExpandAtomicPseudoPass(PassRegistry &); -FunctionPass *createRISCVCleanupVSETVLIPass(); -void initializeRISCVCleanupVSETVLIPass(PassRegistry &); +FunctionPass *createRISCVInsertVSETVLIPass(); +void initializeRISCVInsertVSETVLIPass(PassRegistry &); InstructionSelector *createRISCVInstructionSelector(const RISCVTargetMachine &, RISCVSubtarget &, diff --git a/llvm/lib/Target/RISCV/RISCVCleanupVSETVLI.cpp b/llvm/lib/Target/RISCV/RISCVCleanupVSETVLI.cpp deleted file mode 100644 --- a/llvm/lib/Target/RISCV/RISCVCleanupVSETVLI.cpp +++ /dev/null @@ -1,163 +0,0 @@ -//===- RISCVCleanupVSETVLI.cpp - Cleanup unneeded VSETVLI instructions ----===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// This file implements a function pass that removes duplicate vsetvli -// instructions within a basic block. -// -//===----------------------------------------------------------------------===// - -#include "RISCV.h" -#include "RISCVSubtarget.h" -#include "llvm/CodeGen/MachineFunctionPass.h" -using namespace llvm; - -#define DEBUG_TYPE "riscv-cleanup-vsetvli" -#define RISCV_CLEANUP_VSETVLI_NAME "RISCV Cleanup VSETVLI pass" - -namespace { - -class RISCVCleanupVSETVLI : public MachineFunctionPass { -public: - static char ID; - - RISCVCleanupVSETVLI() : MachineFunctionPass(ID) { - initializeRISCVCleanupVSETVLIPass(*PassRegistry::getPassRegistry()); - } - bool runOnMachineFunction(MachineFunction &MF) override; - bool runOnMachineBasicBlock(MachineBasicBlock &MBB); - - MachineFunctionProperties getRequiredProperties() const override { - return MachineFunctionProperties().set( - MachineFunctionProperties::Property::IsSSA); - } - - // This pass modifies the program, but does not modify the CFG - void getAnalysisUsage(AnalysisUsage &AU) const override { - AU.setPreservesCFG(); - MachineFunctionPass::getAnalysisUsage(AU); - } - - StringRef getPassName() const override { return RISCV_CLEANUP_VSETVLI_NAME; } -}; - -} // end anonymous namespace - -char RISCVCleanupVSETVLI::ID = 0; - -INITIALIZE_PASS(RISCVCleanupVSETVLI, DEBUG_TYPE, - RISCV_CLEANUP_VSETVLI_NAME, false, false) - -static bool isRedundantVSETVLI(MachineInstr &MI, MachineInstr *PrevVSETVLI) { - // If we don't have a previous VSET{I}VLI or the VL output isn't dead, we - // can't remove this VSETVLI. - if (!PrevVSETVLI || !MI.getOperand(0).isDead()) - return false; - - // Does this VSET{I}VLI use the same VTYPE immediate. - int64_t PrevVTYPEImm = PrevVSETVLI->getOperand(2).getImm(); - int64_t VTYPEImm = MI.getOperand(2).getImm(); - if (PrevVTYPEImm != VTYPEImm) - return false; - - if (MI.getOpcode() == RISCV::PseudoVSETIVLI) { - // If the previous opcode wasn't vsetivli we can't compare them. - if (PrevVSETVLI->getOpcode() != RISCV::PseudoVSETIVLI) - return false; - - // For VSETIVLI, we can just compare the immediates. - return PrevVSETVLI->getOperand(1).getImm() == MI.getOperand(1).getImm(); - } - - assert(MI.getOpcode() == RISCV::PseudoVSETVLI); - Register AVLReg = MI.getOperand(1).getReg(); - Register PrevOutVL = PrevVSETVLI->getOperand(0).getReg(); - - // If this VSETVLI isn't changing VL, it is redundant. - if (AVLReg == RISCV::X0 && MI.getOperand(0).getReg() == RISCV::X0) - return true; - - // If the previous VSET{I}VLI's output (which isn't X0) is fed into this - // VSETVLI, this one isn't changing VL so is redundant. - // Only perform this on virtual registers to avoid the complexity of having - // to work out if the physical register was clobbered somewhere in between. - if (AVLReg.isVirtual() && AVLReg == PrevOutVL) - return true; - - // If the previous opcode isn't vsetvli we can't do any more comparison. - if (PrevVSETVLI->getOpcode() != RISCV::PseudoVSETVLI) - return false; - - // Does this VSETVLI use the same AVL register? - if (AVLReg != PrevVSETVLI->getOperand(1).getReg()) - return false; - - // If the AVLReg is X0 we must be setting VL to VLMAX. Keeping VL unchanged - // was handled above. - if (AVLReg == RISCV::X0) { - // This instruction is setting VL to VLMAX, this is redundant if the - // previous VSETVLI was also setting VL to VLMAX. But it is not redundant - // if they were setting it to any other value or leaving VL unchanged. - return PrevOutVL != RISCV::X0; - } - - // This vsetvli is redundant. - return true; -} - -bool RISCVCleanupVSETVLI::runOnMachineBasicBlock(MachineBasicBlock &MBB) { - bool Changed = false; - MachineInstr *PrevVSETVLI = nullptr; - - for (auto MII = MBB.begin(), MIE = MBB.end(); MII != MIE;) { - MachineInstr &MI = *MII++; - - if (MI.getOpcode() != RISCV::PseudoVSETVLI && - MI.getOpcode() != RISCV::PseudoVSETIVLI) { - if (PrevVSETVLI && - (MI.isCall() || MI.modifiesRegister(RISCV::VL) || - MI.modifiesRegister(RISCV::VTYPE))) { - // Old VL/VTYPE is overwritten. - PrevVSETVLI = nullptr; - } - continue; - } - - if (isRedundantVSETVLI(MI, PrevVSETVLI)) { - // This VSETVLI is redundant, remove it. - MI.eraseFromParent(); - Changed = true; - } else { - // Otherwise update VSET{I}VLI for the next iteration. - PrevVSETVLI = &MI; - } - } - - return Changed; -} - -bool RISCVCleanupVSETVLI::runOnMachineFunction(MachineFunction &MF) { - if (skipFunction(MF.getFunction())) - return false; - - // Skip if the vector extension is not enabled. - const RISCVSubtarget &ST = MF.getSubtarget(); - if (!ST.hasStdExtV()) - return false; - - bool Changed = false; - - for (MachineBasicBlock &MBB : MF) - Changed |= runOnMachineBasicBlock(MBB); - - return Changed; -} - -/// Returns an instance of the Cleanup VSETVLI pass. -FunctionPass *llvm::createRISCVCleanupVSETVLIPass() { - return new RISCVCleanupVSETVLI(); -} diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp --- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp @@ -6421,107 +6421,9 @@ return TailMBB; } -static MachineInstr *elideCopies(MachineInstr *MI, - const MachineRegisterInfo &MRI) { - while (true) { - if (!MI->isFullCopy()) - return MI; - if (!Register::isVirtualRegister(MI->getOperand(1).getReg())) - return nullptr; - MI = MRI.getVRegDef(MI->getOperand(1).getReg()); - if (!MI) - return nullptr; - } -} - -static MachineBasicBlock *addVSetVL(MachineInstr &MI, MachineBasicBlock *BB, - int VLIndex, unsigned SEWIndex, - RISCVVLMUL VLMul, bool ForceTailAgnostic) { - MachineFunction &MF = *BB->getParent(); - DebugLoc DL = MI.getDebugLoc(); - const TargetInstrInfo &TII = *MF.getSubtarget().getInstrInfo(); - - unsigned Log2SEW = MI.getOperand(SEWIndex).getImm(); - assert(RISCVVType::isValidSEW(1 << Log2SEW) && "Unexpected SEW"); - RISCVVSEW ElementWidth = static_cast(Log2SEW - 3); - - MachineRegisterInfo &MRI = MF.getRegInfo(); - - auto BuildVSETVLI = [&]() { - if (VLIndex >= 0) { - Register DestReg = MRI.createVirtualRegister(&RISCV::GPRRegClass); - const MachineOperand &VLOp = MI.getOperand(VLIndex); - - // VL can be a register or an immediate. - if (VLOp.isImm()) - return BuildMI(*BB, MI, DL, TII.get(RISCV::PseudoVSETIVLI)) - .addReg(DestReg, RegState::Define | RegState::Dead) - .addImm(VLOp.getImm()); - - Register VLReg = MI.getOperand(VLIndex).getReg(); - return BuildMI(*BB, MI, DL, TII.get(RISCV::PseudoVSETVLI)) - .addReg(DestReg, RegState::Define | RegState::Dead) - .addReg(VLReg); - } - - // With no VL operator in the pseudo, do not modify VL (rd = X0, rs1 = X0). - return BuildMI(*BB, MI, DL, TII.get(RISCV::PseudoVSETVLI)) - .addReg(RISCV::X0, RegState::Define | RegState::Dead) - .addReg(RISCV::X0, RegState::Kill); - }; - - MachineInstrBuilder MIB = BuildVSETVLI(); - - // Default to tail agnostic unless the destination is tied to a source. In - // that case the user would have some control over the tail values. The tail - // policy is also ignored on instructions that only update element 0 like - // vmv.s.x or reductions so use agnostic there to match the common case. - // FIXME: This is conservatively correct, but we might want to detect that - // the input is undefined. - bool TailAgnostic = true; - unsigned UseOpIdx; - if (!ForceTailAgnostic && MI.isRegTiedToUseOperand(0, &UseOpIdx)) { - TailAgnostic = false; - // If the tied operand is an IMPLICIT_DEF we can keep TailAgnostic. - const MachineOperand &UseMO = MI.getOperand(UseOpIdx); - MachineInstr *UseMI = MRI.getVRegDef(UseMO.getReg()); - if (UseMI) { - UseMI = elideCopies(UseMI, MRI); - if (UseMI && UseMI->isImplicitDef()) - TailAgnostic = true; - } - } - - // For simplicity we reuse the vtype representation here. - MIB.addImm(RISCVVType::encodeVTYPE(VLMul, ElementWidth, - /*TailAgnostic*/ TailAgnostic, - /*MaskAgnostic*/ false)); - - // Remove (now) redundant operands from pseudo - if (VLIndex >= 0 && MI.getOperand(VLIndex).isReg()) { - MI.getOperand(VLIndex).setReg(RISCV::NoRegister); - MI.getOperand(VLIndex).setIsKill(false); - } - - return BB; -} - MachineBasicBlock * RISCVTargetLowering::EmitInstrWithCustomInserter(MachineInstr &MI, MachineBasicBlock *BB) const { - uint64_t TSFlags = MI.getDesc().TSFlags; - - if (TSFlags & RISCVII::HasSEWOpMask) { - unsigned NumOperands = MI.getNumExplicitOperands(); - int VLIndex = (TSFlags & RISCVII::HasVLOpMask) ? NumOperands - 2 : -1; - unsigned SEWIndex = NumOperands - 1; - bool ForceTailAgnostic = TSFlags & RISCVII::ForceTailAgnosticMask; - - RISCVVLMUL VLMul = static_cast((TSFlags & RISCVII::VLMulMask) >> - RISCVII::VLMulShift); - return addVSetVL(MI, BB, VLIndex, SEWIndex, VLMul, ForceTailAgnostic); - } - switch (MI.getOpcode()) { default: llvm_unreachable("Unexpected instr type to insert"); diff --git a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp new file mode 100644 --- /dev/null +++ b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp @@ -0,0 +1,255 @@ +//===- RISCVInsertVSETVLI.cpp - Insert VSETVLI instructions ---------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file implements a function pass that inserts VSETVLI instructions where +// needed. +// +//===----------------------------------------------------------------------===// + +#include "RISCV.h" +#include "RISCVSubtarget.h" +#include "llvm/CodeGen/LiveIntervals.h" +#include "llvm/CodeGen/MachineFunctionPass.h" +using namespace llvm; + +#define DEBUG_TYPE "riscv-insert-vsetvli" +#define RISCV_INSERT_VSETVLI_NAME "RISCV Insert VSETVLI pass" + +namespace { + +class RISCVInsertVSETVLI : public MachineFunctionPass { + const TargetInstrInfo *TII; + MachineRegisterInfo *MRI; + +public: + static char ID; + + RISCVInsertVSETVLI() : MachineFunctionPass(ID) { + initializeRISCVInsertVSETVLIPass(*PassRegistry::getPassRegistry()); + } + bool runOnMachineFunction(MachineFunction &MF) override; + bool runOnMachineBasicBlock(MachineBasicBlock &MBB); + + void getAnalysisUsage(AnalysisUsage &AU) const override { + AU.setPreservesCFG(); + MachineFunctionPass::getAnalysisUsage(AU); + } + + StringRef getPassName() const override { return RISCV_INSERT_VSETVLI_NAME; } + +private: + bool maybeInsertVSETVLI(MachineBasicBlock &MBB, + MachineBasicBlock::iterator MII, + const MachineInstr *&PrevVSETVLI); +}; + +} // end anonymous namespace + +char RISCVInsertVSETVLI::ID = 0; + +INITIALIZE_PASS(RISCVInsertVSETVLI, DEBUG_TYPE, RISCV_INSERT_VSETVLI_NAME, + false, false) + +static MachineInstr *elideCopies(MachineInstr *MI, + const MachineRegisterInfo *MRI) { + while (true) { + if (!MI->isFullCopy()) + return MI; + if (!Register::isVirtualRegister(MI->getOperand(1).getReg())) + return nullptr; + MI = MRI->getVRegDef(MI->getOperand(1).getReg()); + if (!MI) + return nullptr; + } +} + +static unsigned computeVType(const MachineInstr &MI, uint64_t TSFlags, + const MachineRegisterInfo *MRI) { + unsigned NumOperands = MI.getNumExplicitOperands(); + + RISCVVLMUL VLMul = static_cast((TSFlags & RISCVII::VLMulMask) >> + RISCVII::VLMulShift); + + unsigned Log2SEW = MI.getOperand(NumOperands - 1).getImm(); + assert(RISCVVType::isValidSEW(1 << Log2SEW) && "Unexpected SEW"); + RISCVVSEW ElementWidth = static_cast(Log2SEW - 3); + + // Default to tail agnostic unless the destination is tied to a source. + // Unless the source is undef. In that case the user would have some control + // over the tail values. The tail policy is also ignored on instructions + // that only update element 0 like vmv.s.x or reductions so use agnostic + // there to match the common case. + // FIXME: This is conservatively correct, but we might want to detect that + // the input is undefined. + bool ForceTailAgnostic = TSFlags & RISCVII::ForceTailAgnosticMask; + bool TailAgnostic = true; + unsigned UseOpIdx; + if (!ForceTailAgnostic && MI.isRegTiedToUseOperand(0, &UseOpIdx)) { + TailAgnostic = false; + // If the tied operand is an IMPLICIT_DEF we can keep TailAgnostic. + const MachineOperand &UseMO = MI.getOperand(UseOpIdx); + MachineInstr *UseMI = MRI->getVRegDef(UseMO.getReg()); + if (UseMI) { + UseMI = elideCopies(UseMI, MRI); + if (UseMI && UseMI->isImplicitDef()) + TailAgnostic = true; + } + } + + return RISCVVType::encodeVTYPE(VLMul, ElementWidth, + /*TailAgnostic*/ TailAgnostic, + /*MaskAgnostic*/ false); +} + +bool RISCVInsertVSETVLI::maybeInsertVSETVLI(MachineBasicBlock &MBB, + MachineBasicBlock::iterator MII, + const MachineInstr *&PrevVSETVLI) { + MachineInstr &MI = *MII; + + uint64_t TSFlags = MI.getDesc().TSFlags; + if (!(TSFlags & RISCVII::HasSEWOpMask)) + return false; + + // Add VL/VTYPE implicit uses. + MI.addOperand( + MachineOperand::CreateReg(RISCV::VL, /*isDef*/ false, /*isImp*/ true)); + MI.addOperand( + MachineOperand::CreateReg(RISCV::VTYPE, /*isDef*/ false, /*isImp*/ true)); + + unsigned VTypeImm = computeVType(MI, TSFlags, MRI); + + // Invalidate PrevVSETVLI if the vtype doesn't match. + if (PrevVSETVLI && PrevVSETVLI->getOperand(2).getImm() != VTypeImm) + PrevVSETVLI = nullptr; + + DebugLoc DL = MI.getDebugLoc(); + + if (!(TSFlags & RISCVII::HasVLOpMask)) { + // This instruction isn't changing VL, if it has the same VTYPE as the last + // VSETVLI we're done. + if (PrevVSETVLI) + return false; + + auto MIB = BuildMI(MBB, MII, DL, TII->get(RISCV::PseudoVSETVLI)) + .addReg(RISCV::X0, RegState::Define | RegState::Dead) + .addReg(RISCV::X0, RegState::Kill) + .addImm(VTypeImm); + PrevVSETVLI = &*MIB; + return true; + } + + MachineOperand &VLOp = MI.getOperand(MI.getNumExplicitOperands() - 2); + + // First handle the VSETIVLI case. + if (VLOp.isImm()) { + int64_t Imm = VLOp.getImm(); + + // If we have a previous VSETIVLI, we don't need to insert one. The VTYPE + // was checked earlier, so just compare the immediate. + if (PrevVSETVLI && PrevVSETVLI->getOpcode() == RISCV::PseudoVSETIVLI && + PrevVSETVLI->getOperand(1).getImm() == Imm) + return false; + + // TODO: Use X0 as the destination. + Register DestReg = MRI->createVirtualRegister(&RISCV::GPRRegClass); + auto MIB = BuildMI(MBB, MII, DL, TII->get(RISCV::PseudoVSETIVLI)) + .addReg(DestReg, RegState::Define | RegState::Dead) + .addImm(Imm) + .addImm(VTypeImm); + PrevVSETVLI = &*MIB; + + return true; + } + + // Otherwise we expect VL to be a GPR. + Register AVLReg = VLOp.getReg(); + + auto needVSETVLI = [](const MachineInstr *PrevVSETVLI, Register AVLReg) { + if (!PrevVSETVLI) + return true; + + Register PrevOutVL = PrevVSETVLI->getOperand(0).getReg(); + // If the previous VSET{I}VLI's output (which isn't X0) is fed into this + // VSETVLI, this one isn't changing VL so is redundant. + // Only perform this on virtual registers to avoid the complexity of having + // to work out if the physical register was clobbered somewhere in between. + if (AVLReg.isVirtual() && AVLReg == PrevOutVL) + return false; + + if (PrevVSETVLI->getOpcode() == RISCV::PseudoVSETVLI && + AVLReg == PrevVSETVLI->getOperand(1).getReg() && + (AVLReg != RISCV::X0 || PrevOutVL != RISCV::X0)) + return false; + + return true; + }; + + if (needVSETVLI(PrevVSETVLI, AVLReg)) { + // TODO: Use X0 as the destination if AVLReg is not X0. + Register DestReg = MRI->createVirtualRegister(&RISCV::GPRRegClass); + auto MIB = BuildMI(MBB, MII, DL, TII->get(RISCV::PseudoVSETVLI)) + .addReg(DestReg, RegState::Define | RegState::Dead) + .addReg(AVLReg) + .addImm(VTypeImm); + PrevVSETVLI = &*MIB; + } + + // Clear the GPR, the we don't need it anymore + VLOp.setReg(RISCV::NoRegister); + + return true; +} + +bool RISCVInsertVSETVLI::runOnMachineBasicBlock(MachineBasicBlock &MBB) { + bool Changed = false; + const MachineInstr *PrevVSETVLI = nullptr; + + for (auto MII = MBB.begin(), MIE = MBB.end(); MII != MIE; ++MII) { + MachineInstr &MI = *MII; + + // If this is an explicit VSETVLI/VSETIVILI instruction, cache it as our + // previous VL/VTYPE update. + if (MI.getOpcode() == RISCV::PseudoVSETVLI || + MI.getOpcode() == RISCV::PseudoVSETIVLI) { + PrevVSETVLI = &MI; + continue; + } + + Changed |= maybeInsertVSETVLI(MBB, MII, PrevVSETVLI); + + if (PrevVSETVLI && (MI.isCall() || MI.modifiesRegister(RISCV::VL) || + MI.modifiesRegister(RISCV::VTYPE))) { + // Old VL/VTYPE is overwritten. + PrevVSETVLI = nullptr; + } + } + + return Changed; +} + +bool RISCVInsertVSETVLI::runOnMachineFunction(MachineFunction &MF) { + // Skip if the vector extension is not enabled. + const RISCVSubtarget &ST = MF.getSubtarget(); + if (!ST.hasStdExtV()) + return false; + + const RISCVSubtarget &Subtarget = MF.getSubtarget(); + TII = Subtarget.getInstrInfo(); + MRI = &MF.getRegInfo(); + + bool Changed = false; + for (MachineBasicBlock &MBB : MF) + Changed |= runOnMachineBasicBlock(MBB); + + return Changed; +} + +/// Returns an instance of the Insert VSETVLI pass. +FunctionPass *llvm::createRISCVInsertVSETVLIPass() { + return new RISCVInsertVSETVLI(); +} diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td --- a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td @@ -619,8 +619,6 @@ let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; - let usesCustomInserter = 1; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; @@ -637,9 +635,7 @@ let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; - let usesCustomInserter = 1; let Constraints = "$rd = $merge"; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let HasMergeOp = 1; @@ -654,8 +650,6 @@ let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; - let usesCustomInserter = 1; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; @@ -672,9 +666,7 @@ let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; - let usesCustomInserter = 1; let Constraints = "$rd = $merge"; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let HasMergeOp = 1; @@ -690,8 +682,6 @@ let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; - let usesCustomInserter = 1; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; @@ -710,9 +700,7 @@ let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; - let usesCustomInserter = 1; let Constraints = !if(!eq(EarlyClobber, 1), "@earlyclobber $rd, $rd = $merge", "$rd = $merge"); - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let HasMergeOp = 1; @@ -727,8 +715,6 @@ let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; - let usesCustomInserter = 1; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; @@ -743,8 +729,6 @@ let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; - let usesCustomInserter = 1; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let BaseInstr = !cast(PseudoToVInst.VInst); @@ -758,8 +742,6 @@ let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; - let usesCustomInserter = 1; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; @@ -774,8 +756,6 @@ let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; - let usesCustomInserter = 1; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let BaseInstr = !cast(PseudoToVInst.VInst); @@ -790,8 +770,6 @@ let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; - let usesCustomInserter = 1; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let BaseInstr = !cast(PseudoToVInst.VInst); @@ -804,8 +782,6 @@ let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; - let usesCustomInserter = 1; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; @@ -819,9 +795,7 @@ let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; - let usesCustomInserter = 1; let Constraints ="$rd = $merge"; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let HasMergeOp = 1; @@ -836,8 +810,6 @@ let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; - let usesCustomInserter = 1; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; // BaseInstr is not used in RISCVExpandPseudoInsts pass. @@ -853,9 +825,7 @@ let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; - let usesCustomInserter = 1; let Constraints = Constraint; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; @@ -870,9 +840,7 @@ let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; - let usesCustomInserter = 1; let Constraints = Join<[Constraint, "$rd = $merge"], ",">.ret; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let HasMergeOp = 1; @@ -887,8 +855,6 @@ let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; - let usesCustomInserter = 1; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let BaseInstr = !cast(PseudoToVInst.VInst); @@ -906,9 +872,7 @@ let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; - let usesCustomInserter = 1; let Constraints = "@earlyclobber $rd, $rd = $merge"; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let HasMergeOp = 1; @@ -925,9 +889,7 @@ let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; - let usesCustomInserter = 1; let Constraints = Constraint; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; @@ -943,8 +905,6 @@ let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; - let usesCustomInserter = 1; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; @@ -960,8 +920,6 @@ let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; - let usesCustomInserter = 1; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let BaseInstr = !cast(PseudoToVInst.VInst); @@ -979,9 +937,7 @@ let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; - let usesCustomInserter = 1; let Constraints = Join<[Constraint, "$rd = $merge"], ",">.ret; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let HasMergeOp = 1; @@ -1001,9 +957,7 @@ let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; - let usesCustomInserter = 1; let Constraints = Join<[Constraint, "$rd = $merge"], ",">.ret; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let HasMergeOp = 1; @@ -1025,9 +979,7 @@ let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; - let usesCustomInserter = 1; let Constraints = Constraint; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let HasMergeOp = 0; @@ -1047,9 +999,7 @@ let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; - let usesCustomInserter = 1; let Constraints = Join<[Constraint, "$rd = $rs3"], ",">.ret; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let HasMergeOp = 1; @@ -1068,9 +1018,7 @@ let mayLoad = 1; let mayStore = 1; let hasSideEffects = 1; - let usesCustomInserter = 1; let Constraints = "$vd_wd = $vd"; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; @@ -1088,9 +1036,7 @@ let mayLoad = 1; let mayStore = 1; let hasSideEffects = 1; - let usesCustomInserter = 1; let Constraints = "$vd_wd = $vd"; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let BaseInstr = !cast(PseudoToVInst.VInst); @@ -1131,8 +1077,6 @@ let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; - let usesCustomInserter = 1; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; @@ -1148,9 +1092,7 @@ let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; - let usesCustomInserter = 1; let Constraints = "$rd = $merge"; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let HasMergeOp = 1; @@ -1166,8 +1108,6 @@ let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; - let usesCustomInserter = 1; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; @@ -1183,9 +1123,7 @@ let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; - let usesCustomInserter = 1; let Constraints = "$rd = $merge"; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let HasMergeOp = 1; @@ -1201,11 +1139,9 @@ let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; - let usesCustomInserter = 1; // For vector indexed segment loads, the destination vector register groups // cannot overlap the source vector register group let Constraints = "@earlyclobber $rd"; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; @@ -1222,11 +1158,9 @@ let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; - let usesCustomInserter = 1; // For vector indexed segment loads, the destination vector register groups // cannot overlap the source vector register group let Constraints = "@earlyclobber $rd, $rd = $merge"; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let HasMergeOp = 1; @@ -1241,8 +1175,6 @@ let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; - let usesCustomInserter = 1; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; @@ -1258,8 +1190,6 @@ let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; - let usesCustomInserter = 1; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let BaseInstr = !cast(PseudoToVInst.VInst); @@ -1273,8 +1203,6 @@ let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; - let usesCustomInserter = 1; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; @@ -1290,8 +1218,6 @@ let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; - let usesCustomInserter = 1; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let BaseInstr = !cast(PseudoToVInst.VInst); @@ -1307,8 +1233,6 @@ let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; - let usesCustomInserter = 1; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; @@ -1325,8 +1249,6 @@ let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; - let usesCustomInserter = 1; - let Uses = [VL, VTYPE]; let HasVLOp = 1; let HasSEWOp = 1; let BaseInstr = !cast(PseudoToVInst.VInst); @@ -3521,7 +3443,7 @@ //===----------------------------------------------------------------------===// // 13.2. Vector Single-Width Averaging Add and Subtract //===----------------------------------------------------------------------===// -let Uses = [VL, VTYPE, VXRM], hasSideEffects = 1 in { +let Uses = [VXRM], hasSideEffects = 1 in { defm PseudoVAADDU : VPseudoBinaryV_VV_VX; defm PseudoVAADD : VPseudoBinaryV_VV_VX; defm PseudoVASUBU : VPseudoBinaryV_VV_VX; @@ -3531,14 +3453,14 @@ //===----------------------------------------------------------------------===// // 13.3. Vector Single-Width Fractional Multiply with Rounding and Saturation //===----------------------------------------------------------------------===// -let Uses = [VL, VTYPE, VXRM], Defs = [VXSAT], hasSideEffects = 1 in { +let Uses = [VXRM], Defs = [VXSAT], hasSideEffects = 1 in { defm PseudoVSMUL : VPseudoBinaryV_VV_VX; } //===----------------------------------------------------------------------===// // 13.4. Vector Single-Width Scaling Shift Instructions //===----------------------------------------------------------------------===// -let Uses = [VL, VTYPE, VXRM], hasSideEffects = 1 in { +let Uses = [VXRM], hasSideEffects = 1 in { defm PseudoVSSRL : VPseudoBinaryV_VV_VX_VI; defm PseudoVSSRA : VPseudoBinaryV_VV_VX_VI; } @@ -3546,7 +3468,7 @@ //===----------------------------------------------------------------------===// // 13.5. Vector Narrowing Fixed-Point Clip Instructions //===----------------------------------------------------------------------===// -let Uses = [VL, VTYPE, VXRM], Defs = [VXSAT], hasSideEffects = 1 in { +let Uses = [VXRM], Defs = [VXSAT], hasSideEffects = 1 in { defm PseudoVNCLIP : VPseudoBinaryV_WV_WX_WI; defm PseudoVNCLIPU : VPseudoBinaryV_WV_WX_WI; } @@ -3792,8 +3714,7 @@ //===----------------------------------------------------------------------===// let Predicates = [HasStdExtV] in { -let mayLoad = 0, mayStore = 0, hasSideEffects = 0, usesCustomInserter = 1, - Uses = [VL, VTYPE] in { +let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in { foreach m = MxList.m in { let VLMul = m.value in { let HasSEWOp = 1, BaseInstr = VMV_X_S in @@ -3816,8 +3737,7 @@ //===----------------------------------------------------------------------===// let Predicates = [HasStdExtV, HasStdExtF] in { -let mayLoad = 0, mayStore = 0, hasSideEffects = 0, usesCustomInserter = 1, - Uses = [VL, VTYPE] in { +let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in { foreach m = MxList.m in { foreach f = FPList.fpinfo in { let VLMul = m.value in { diff --git a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp --- a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp +++ b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp @@ -39,7 +39,7 @@ initializeGlobalISel(*PR); initializeRISCVMergeBaseOffsetOptPass(*PR); initializeRISCVExpandPseudoPass(*PR); - initializeRISCVCleanupVSETVLIPass(*PR); + initializeRISCVInsertVSETVLIPass(*PR); } static StringRef computeDataLayout(const Triple &TT) { @@ -191,8 +191,7 @@ } void RISCVPassConfig::addPreRegAlloc() { - if (TM->getOptLevel() != CodeGenOpt::None) { + if (TM->getOptLevel() != CodeGenOpt::None) addPass(createRISCVMergeBaseOffsetOptPass()); - addPass(createRISCVCleanupVSETVLIPass()); - } + addPass(createRISCVInsertVSETVLIPass()); } diff --git a/llvm/test/CodeGen/RISCV/rvv/add-vsetvli-gpr.mir b/llvm/test/CodeGen/RISCV/rvv/add-vsetvli-gpr.mir deleted file mode 100644 --- a/llvm/test/CodeGen/RISCV/rvv/add-vsetvli-gpr.mir +++ /dev/null @@ -1,56 +0,0 @@ -# RUN: llc -mtriple riscv64 -mattr=+experimental-v %s \ -# RUN: -start-before=finalize-isel -stop-after=finalize-isel -o - \ -# RUN: | FileCheck --check-prefix=POST-INSERTER %s - -# RUN: llc -mtriple riscv64 -mattr=+experimental-v %s \ -# RUN: -start-before=finalize-isel -o - \ -# RUN: | FileCheck --check-prefix=CODEGEN %s - ---- | - define void @vadd_vint64m1( - *%pc, - *%pa, - *%pb, - i64 %vl) - { - ret void - } -... ---- -name: vadd_vint64m1 -tracksRegLiveness: true -body: | - bb.0 (%ir-block.0): - liveins: $x10, $x11, $x12, $x13 - - %3:gpr = COPY $x13 - %2:gpr = COPY $x12 - %1:gpr = COPY $x11 - %0:gpr = COPY $x10 - %4:vr = PseudoVLE64_V_M1 %1, %3, 6, implicit $vl, implicit $vtype :: (load unknown-size from %ir.pa, align 8) - %5:vr = PseudoVLE64_V_M1 %2, %3, 6, implicit $vl, implicit $vtype :: (load unknown-size from %ir.pb, align 8) - %6:vr = PseudoVADD_VV_M1 killed %4, killed %5, %3, 6, implicit $vl, implicit $vtype - PseudoVSE64_V_M1 killed %6, %0, %3, 6, implicit $vl, implicit $vtype :: (store unknown-size into %ir.pc, align 8) - PseudoRET - -... - -# POST-INSERTER: %0:gpr = COPY $x13 -# POST-INSERTER: %1:gpr = COPY $x12 -# POST-INSERTER: %2:gpr = COPY $x11 -# POST-INSERTER: %3:gpr = COPY $x10 -# POST-INSERTER: dead %7:gpr = PseudoVSETVLI %0, 88, implicit-def $vl, implicit-def $vtype -# POST-INSERTER: %4:vr = PseudoVLE64_V_M1 %2, $noreg, 6, implicit $vl, implicit $vtype :: (load unknown-size from %ir.pa, align 8) -# POST-INSERTER: dead %8:gpr = PseudoVSETVLI %0, 88, implicit-def $vl, implicit-def $vtype -# POST-INSERTER: %5:vr = PseudoVLE64_V_M1 %1, $noreg, 6, implicit $vl, implicit $vtype :: (load unknown-size from %ir.pb, align 8) -# POST-INSERTER: dead %9:gpr = PseudoVSETVLI %0, 88, implicit-def $vl, implicit-def $vtype -# POST-INSERTER: %6:vr = PseudoVADD_VV_M1 killed %4, killed %5, $noreg, 6, implicit $vl, implicit $vtype -# POST-INSERTER: dead %10:gpr = PseudoVSETVLI %0, 88, implicit-def $vl, implicit-def $vtype -# POST-INSERTER: PseudoVSE64_V_M1 killed %6, %3, $noreg, 6, implicit $vl, implicit $vtype :: (store unknown-size into %ir.pc, align 8) - -# CODEGEN: vsetvli a3, a3, e64,m1,ta,mu -# CODEGEN-NEXT: vle64.v v25, (a1) -# CODEGEN-NEXT: vle64.v v26, (a2) -# CODEGEN-NEXT: vadd.vv v25, v25, v26 -# CODEGEN-NEXT: vse64.v v25, (a0) -# CODEGEN-NEXT: ret diff --git a/llvm/test/CodeGen/RISCV/rvv/add-vsetvli-vlmax.ll b/llvm/test/CodeGen/RISCV/rvv/add-vsetvli-vlmax.ll deleted file mode 100644 --- a/llvm/test/CodeGen/RISCV/rvv/add-vsetvli-vlmax.ll +++ /dev/null @@ -1,32 +0,0 @@ -; This test shows the evolution of RVV pseudo instructions within isel. - -; RUN: llc -mtriple riscv64 -mattr=+experimental-v %s -o %t.pre.mir \ -; RUN: -stop-before=finalize-isel -; RUN: cat %t.pre.mir | FileCheck --check-prefix=PRE-INSERTER %s - -; RUN: llc -mtriple riscv64 -mattr=+experimental-v %t.pre.mir -o %t.post.mir \ -; RUN: -start-before=finalize-isel -stop-after=finalize-isel -; RUN: cat %t.post.mir | FileCheck --check-prefix=POST-INSERTER %s - -define void @vadd_vint64m1( - *%pc, - *%pa, - *%pb) -{ - %va = load , * %pa - %vb = load , * %pb - %vc = add %va, %vb - store %vc, *%pc - ret void -} - -; PRE-INSERTER: %3:vr = VL1RE64_V %1 :: (load unknown-size from %ir.pa, align 8) -; PRE-INSERTER: %4:vr = VL1RE64_V %2 :: (load unknown-size from %ir.pb, align 8) -; PRE-INSERTER: %5:vr = PseudoVADD_VV_M1 killed %3, killed %4, $x0, 6, implicit $vl, implicit $vtype -; PRE-INSERTER: VS1R_V killed %5, %0 :: (store unknown-size into %ir.pc, align 8) - -; POST-INSERTER: %3:vr = VL1RE64_V %1 :: (load unknown-size from %ir.pa, align 8) -; POST-INSERTER: %4:vr = VL1RE64_V %2 :: (load unknown-size from %ir.pb, align 8) -; POST-INSERTER: dead %6:gpr = PseudoVSETVLI $x0, 88, implicit-def $vl, implicit-def $vtype -; POST-INSERTER: %5:vr = PseudoVADD_VV_M1 killed %3, killed %4, $noreg, 6, implicit $vl, implicit $vtype -; POST-INSERTER: VS1R_V killed %5, %0 :: (store unknown-size into %ir.pc, align 8) diff --git a/llvm/test/CodeGen/RISCV/rvv/addi-scalable-offset.mir b/llvm/test/CodeGen/RISCV/rvv/addi-scalable-offset.mir --- a/llvm/test/CodeGen/RISCV/rvv/addi-scalable-offset.mir +++ b/llvm/test/CodeGen/RISCV/rvv/addi-scalable-offset.mir @@ -38,8 +38,7 @@ ; CHECK: $x2 = frame-setup ADDI $x2, -240 ; CHECK: $x12 = PseudoReadVLENB ; CHECK: $x2 = SUB $x2, killed $x12 - ; CHECK: dead renamable $x11 = PseudoVSETVLI killed renamable $x11, 88, implicit-def $vl, implicit-def $vtype - ; CHECK: renamable $v25 = PseudoVLE64_V_M1 killed renamable $x10, $noreg, 6, implicit $vl, implicit $vtype :: (load unknown-size from %ir.pa, align 8) + ; CHECK: renamable $v25 = PseudoVLE64_V_M1 killed renamable $x10, killed renamable $x11, 6, implicit $vl, implicit $vtype :: (load unknown-size from %ir.pa, align 8) ; CHECK: $x11 = PseudoReadVLENB ; CHECK: $x10 = LUI 1048575 ; CHECK: $x10 = ADDIW killed $x10, 1824 diff --git a/llvm/test/CodeGen/RISCV/rvv/cleanup-vsetivli.mir b/llvm/test/CodeGen/RISCV/rvv/cleanup-vsetivli.mir deleted file mode 100644 --- a/llvm/test/CodeGen/RISCV/rvv/cleanup-vsetivli.mir +++ /dev/null @@ -1,46 +0,0 @@ -# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py -# RUN: llc %s -mtriple=riscv64 -run-pass=riscv-cleanup-vsetvli -o - | FileCheck %s - -# Make sure we don't combine these VSET{I}VLIs in the cleanup pass. We could not -# differentiate AVL values if the opcode of the previous one is different from -# current one. - ---- | - ; ModuleID = '../llvm/test/CodeGen/RISCV/rvv/add-vsetivli.ll' - source_filename = "../llvm/test/CodeGen/RISCV/rvv/add-vsetivli.ll" - target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" - target triple = "riscv64" - - define void @cleanup_vsetivli() #0 { - ret void - } - - attributes #0 = { "target-features"="+experimental-v" } - -... ---- -name: cleanup_vsetivli -alignment: 4 -tracksRegLiveness: true -registers: - - { id: 0, class: gpr } -frameInfo: - maxAlignment: 1 -machineFunctionInfo: {} -body: | - bb.0 (%ir-block.0): - ; CHECK-LABEL: name: cleanup_vsetivli - ; CHECK: dead %0:gpr = PseudoVSETVLI $x0, 12, implicit-def $vl, implicit-def $vtype - ; CHECK: dead %1:gpr = PseudoVSETIVLI 5, 12, implicit-def $vl, implicit-def $vtype - ; CHECK: dead %3:gpr = PseudoVSETVLI $x0, 12, implicit-def $vl, implicit-def $vtype - ; CHECK: dead %5:gpr = PseudoVSETIVLI 5, 12, implicit-def $vl, implicit-def $vtype - ; CHECK: PseudoRET - dead %0:gpr = PseudoVSETVLI $x0, 12, implicit-def $vl, implicit-def $vtype - dead %1:gpr = PseudoVSETIVLI 5, 12, implicit-def $vl, implicit-def $vtype - dead %2:gpr = PseudoVSETIVLI 5, 12, implicit-def $vl, implicit-def $vtype - dead %3:gpr = PseudoVSETVLI $x0, 12, implicit-def $vl, implicit-def $vtype - dead %4:gpr = PseudoVSETVLI $x0, 12, implicit-def $vl, implicit-def $vtype - dead %5:gpr = PseudoVSETIVLI 5, 12, implicit-def $vl, implicit-def $vtype - PseudoRET - -... diff --git a/llvm/test/CodeGen/RISCV/rvv/cleanup-vsetvli.mir b/llvm/test/CodeGen/RISCV/rvv/cleanup-vsetvli.mir deleted file mode 100644 --- a/llvm/test/CodeGen/RISCV/rvv/cleanup-vsetvli.mir +++ /dev/null @@ -1,79 +0,0 @@ -# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py -# RUN: llc %s -mtriple=riscv64 -run-pass=riscv-cleanup-vsetvli -o - | FileCheck %s - ---- | - ; ModuleID = '../llvm/test/CodeGen/RISCV/rvv/add-vsetvli-vlmax.ll' - source_filename = "../llvm/test/CodeGen/RISCV/rvv/add-vsetvli-vlmax.ll" - target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" - target triple = "riscv64" - - define void @cleanup_vsetvli0() #0 { - ret void - } - - define void @cleanup_vsetvli1() #0 { - ret void - } - - attributes #0 = { "target-features"="+experimental-v" } - -... ---- -# Make sure we don't combine these two VSETVLIs in the cleanup pass. The first -# keeps the previous value of VL, the second sets it to VLMAX. We can't remove -# the first since we can't tell if this is a change of VL. -name: cleanup_vsetvli0 -alignment: 4 -tracksRegLiveness: true -registers: - - { id: 0, class: gpr } -frameInfo: - maxAlignment: 1 -machineFunctionInfo: {} -body: | - bb.0 (%ir-block.0): - ; CHECK-LABEL: name: cleanup_vsetvli0 - ; CHECK: dead $x0 = PseudoVSETVLI $x0, 12, implicit-def $vl, implicit-def $vtype - ; CHECK: dead %0:gpr = PseudoVSETVLI $x0, 12, implicit-def $vl, implicit-def $vtype - ; CHECK: PseudoRET - dead $x0 = PseudoVSETVLI $x0, 12, implicit-def $vl, implicit-def $vtype - dead %0:gpr = PseudoVSETVLI $x0, 12, implicit-def $vl, implicit-def $vtype - PseudoRET - -... ---- -# 1. Ensure we can remove the second VSETVLI which takes its AVL from the first VSETVLI. -# 2. Ensure we can remove the fourth VSETVLI which takes its AVL from the VSETIVLI. -# 3. Make sure we don't combine the latter two VSETVLIs; the first outputs to a -# physical register which is clobbered by a later instruction. -name: cleanup_vsetvli1 -alignment: 4 -tracksRegLiveness: true -registers: - - { id: 0, class: gpr } -frameInfo: - maxAlignment: 1 -machineFunctionInfo: {} -body: | - bb.0 (%ir-block.0): - liveins: $x3 - ; CHECK-LABEL: name: cleanup_vsetvli1 - ; CHECK: liveins: $x3 - ; CHECK: [[PseudoVSETVLI:%[0-9]+]]:gpr = PseudoVSETVLI $x0, 12, implicit-def $vl, implicit-def $vtype - ; CHECK: [[PseudoVSETIVLI:%[0-9]+]]:gpr = PseudoVSETIVLI 4, 12, implicit-def $vl, implicit-def $vtype - ; CHECK: $x1 = PseudoVSETVLI $x0, 12, implicit-def $vl, implicit-def $vtype - ; CHECK: $x1 = COPY $x3 - ; CHECK: dead %4:gpr = PseudoVSETVLI $x1, 12, implicit-def $vl, implicit-def $vtype - ; CHECK: PseudoRET - %0:gpr = PseudoVSETVLI $x0, 12, implicit-def $vl, implicit-def $vtype - dead %1:gpr = PseudoVSETVLI %0, 12, implicit-def $vl, implicit-def $vtype - - %2:gpr = PseudoVSETIVLI 4, 12, implicit-def $vl, implicit-def $vtype - dead %3:gpr = PseudoVSETVLI %2, 12, implicit-def $vl, implicit-def $vtype - - $x1 = PseudoVSETVLI $x0, 12, implicit-def $vl, implicit-def $vtype - $x1 = COPY $x3 - dead %4:gpr = PseudoVSETVLI $x1, 12, implicit-def $vl, implicit-def $vtype - PseudoRET - -... diff --git a/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-ctlz.ll b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-ctlz.ll --- a/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-ctlz.ll +++ b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-ctlz.ll @@ -3667,11 +3667,12 @@ ; LMULMAX2-RV32-NEXT: addi a3, a1, 819 ; LMULMAX2-RV32-NEXT: lui a1, 61681 ; LMULMAX2-RV32-NEXT: addi a7, a1, -241 -; LMULMAX2-RV32-NEXT: lui a1, 4112 -; LMULMAX2-RV32-NEXT: addi a2, a1, 257 -; LMULMAX2-RV32-NEXT: vmv.x.s a1, v25 +; LMULMAX2-RV32-NEXT: lui a2, 4112 +; LMULMAX2-RV32-NEXT: addi a2, a2, 257 ; LMULMAX2-RV32-NEXT: bnez a5, .LBB3_2 ; LMULMAX2-RV32-NEXT: # %bb.1: +; LMULMAX2-RV32-NEXT: vsetvli zero, zero, e64,m1,ta,mu +; LMULMAX2-RV32-NEXT: vmv.x.s a1, v25 ; LMULMAX2-RV32-NEXT: srli a5, a1, 1 ; LMULMAX2-RV32-NEXT: or a1, a1, a5 ; LMULMAX2-RV32-NEXT: srli a5, a1, 2 @@ -3726,12 +3727,13 @@ ; LMULMAX2-RV32-NEXT: vsetivli a1, 1, e64,m1,ta,mu ; LMULMAX2-RV32-NEXT: vslidedown.vi v25, v25, 1 ; LMULMAX2-RV32-NEXT: vsrl.vx v26, v25, a6 -; LMULMAX2-RV32-NEXT: vmv.x.s a1, v26 -; LMULMAX2-RV32-NEXT: vmv.x.s a5, v25 -; LMULMAX2-RV32-NEXT: bnez a1, .LBB3_5 +; LMULMAX2-RV32-NEXT: vmv.x.s a5, v26 +; LMULMAX2-RV32-NEXT: bnez a5, .LBB3_5 ; LMULMAX2-RV32-NEXT: # %bb.4: -; LMULMAX2-RV32-NEXT: srli a1, a5, 1 -; LMULMAX2-RV32-NEXT: or a1, a5, a1 +; LMULMAX2-RV32-NEXT: vsetvli zero, zero, e64,m1,ta,mu +; LMULMAX2-RV32-NEXT: vmv.x.s a1, v25 +; LMULMAX2-RV32-NEXT: srli a5, a1, 1 +; LMULMAX2-RV32-NEXT: or a1, a1, a5 ; LMULMAX2-RV32-NEXT: srli a5, a1, 2 ; LMULMAX2-RV32-NEXT: or a1, a1, a5 ; LMULMAX2-RV32-NEXT: srli a5, a1, 4 @@ -3756,8 +3758,8 @@ ; LMULMAX2-RV32-NEXT: addi a1, a1, 32 ; LMULMAX2-RV32-NEXT: j .LBB3_6 ; LMULMAX2-RV32-NEXT: .LBB3_5: -; LMULMAX2-RV32-NEXT: srli a5, a1, 1 -; LMULMAX2-RV32-NEXT: or a1, a1, a5 +; LMULMAX2-RV32-NEXT: srli a1, a5, 1 +; LMULMAX2-RV32-NEXT: or a1, a5, a1 ; LMULMAX2-RV32-NEXT: srli a5, a1, 2 ; LMULMAX2-RV32-NEXT: or a1, a1, a5 ; LMULMAX2-RV32-NEXT: srli a5, a1, 4 @@ -3900,11 +3902,12 @@ ; LMULMAX1-RV32-NEXT: addi a3, a1, 819 ; LMULMAX1-RV32-NEXT: lui a1, 61681 ; LMULMAX1-RV32-NEXT: addi a7, a1, -241 -; LMULMAX1-RV32-NEXT: lui a1, 4112 -; LMULMAX1-RV32-NEXT: addi a2, a1, 257 -; LMULMAX1-RV32-NEXT: vmv.x.s a1, v25 +; LMULMAX1-RV32-NEXT: lui a2, 4112 +; LMULMAX1-RV32-NEXT: addi a2, a2, 257 ; LMULMAX1-RV32-NEXT: bnez a5, .LBB3_2 ; LMULMAX1-RV32-NEXT: # %bb.1: +; LMULMAX1-RV32-NEXT: vsetvli zero, zero, e64,m1,ta,mu +; LMULMAX1-RV32-NEXT: vmv.x.s a1, v25 ; LMULMAX1-RV32-NEXT: srli a5, a1, 1 ; LMULMAX1-RV32-NEXT: or a1, a1, a5 ; LMULMAX1-RV32-NEXT: srli a5, a1, 2 @@ -3959,12 +3962,13 @@ ; LMULMAX1-RV32-NEXT: vsetivli a1, 1, e64,m1,ta,mu ; LMULMAX1-RV32-NEXT: vslidedown.vi v25, v25, 1 ; LMULMAX1-RV32-NEXT: vsrl.vx v26, v25, a6 -; LMULMAX1-RV32-NEXT: vmv.x.s a1, v26 -; LMULMAX1-RV32-NEXT: vmv.x.s a5, v25 -; LMULMAX1-RV32-NEXT: bnez a1, .LBB3_5 +; LMULMAX1-RV32-NEXT: vmv.x.s a5, v26 +; LMULMAX1-RV32-NEXT: bnez a5, .LBB3_5 ; LMULMAX1-RV32-NEXT: # %bb.4: -; LMULMAX1-RV32-NEXT: srli a1, a5, 1 -; LMULMAX1-RV32-NEXT: or a1, a5, a1 +; LMULMAX1-RV32-NEXT: vsetvli zero, zero, e64,m1,ta,mu +; LMULMAX1-RV32-NEXT: vmv.x.s a1, v25 +; LMULMAX1-RV32-NEXT: srli a5, a1, 1 +; LMULMAX1-RV32-NEXT: or a1, a1, a5 ; LMULMAX1-RV32-NEXT: srli a5, a1, 2 ; LMULMAX1-RV32-NEXT: or a1, a1, a5 ; LMULMAX1-RV32-NEXT: srli a5, a1, 4 @@ -3989,8 +3993,8 @@ ; LMULMAX1-RV32-NEXT: addi a1, a1, 32 ; LMULMAX1-RV32-NEXT: j .LBB3_6 ; LMULMAX1-RV32-NEXT: .LBB3_5: -; LMULMAX1-RV32-NEXT: srli a5, a1, 1 -; LMULMAX1-RV32-NEXT: or a1, a1, a5 +; LMULMAX1-RV32-NEXT: srli a1, a5, 1 +; LMULMAX1-RV32-NEXT: or a1, a5, a1 ; LMULMAX1-RV32-NEXT: srli a5, a1, 2 ; LMULMAX1-RV32-NEXT: or a1, a1, a5 ; LMULMAX1-RV32-NEXT: srli a5, a1, 4 @@ -11120,11 +11124,12 @@ ; LMULMAX2-RV32-NEXT: addi a3, a1, 819 ; LMULMAX2-RV32-NEXT: lui a1, 61681 ; LMULMAX2-RV32-NEXT: addi a7, a1, -241 -; LMULMAX2-RV32-NEXT: lui a1, 4112 -; LMULMAX2-RV32-NEXT: addi a2, a1, 257 -; LMULMAX2-RV32-NEXT: vmv.x.s a1, v26 +; LMULMAX2-RV32-NEXT: lui a2, 4112 +; LMULMAX2-RV32-NEXT: addi a2, a2, 257 ; LMULMAX2-RV32-NEXT: bnez a5, .LBB7_2 ; LMULMAX2-RV32-NEXT: # %bb.1: +; LMULMAX2-RV32-NEXT: vsetvli zero, zero, e64,m2,ta,mu +; LMULMAX2-RV32-NEXT: vmv.x.s a1, v26 ; LMULMAX2-RV32-NEXT: srli a5, a1, 1 ; LMULMAX2-RV32-NEXT: or a1, a1, a5 ; LMULMAX2-RV32-NEXT: srli a5, a1, 2 @@ -11179,12 +11184,13 @@ ; LMULMAX2-RV32-NEXT: vsetivli a1, 1, e64,m2,ta,mu ; LMULMAX2-RV32-NEXT: vslidedown.vi v28, v26, 3 ; LMULMAX2-RV32-NEXT: vsrl.vx v30, v28, a6 -; LMULMAX2-RV32-NEXT: vmv.x.s a1, v30 -; LMULMAX2-RV32-NEXT: vmv.x.s a5, v28 -; LMULMAX2-RV32-NEXT: bnez a1, .LBB7_5 +; LMULMAX2-RV32-NEXT: vmv.x.s a5, v30 +; LMULMAX2-RV32-NEXT: bnez a5, .LBB7_5 ; LMULMAX2-RV32-NEXT: # %bb.4: -; LMULMAX2-RV32-NEXT: srli a1, a5, 1 -; LMULMAX2-RV32-NEXT: or a1, a5, a1 +; LMULMAX2-RV32-NEXT: vsetvli zero, zero, e64,m2,ta,mu +; LMULMAX2-RV32-NEXT: vmv.x.s a1, v28 +; LMULMAX2-RV32-NEXT: srli a5, a1, 1 +; LMULMAX2-RV32-NEXT: or a1, a1, a5 ; LMULMAX2-RV32-NEXT: srli a5, a1, 2 ; LMULMAX2-RV32-NEXT: or a1, a1, a5 ; LMULMAX2-RV32-NEXT: srli a5, a1, 4 @@ -11209,8 +11215,8 @@ ; LMULMAX2-RV32-NEXT: addi a5, a1, 32 ; LMULMAX2-RV32-NEXT: j .LBB7_6 ; LMULMAX2-RV32-NEXT: .LBB7_5: -; LMULMAX2-RV32-NEXT: srli a5, a1, 1 -; LMULMAX2-RV32-NEXT: or a1, a1, a5 +; LMULMAX2-RV32-NEXT: srli a1, a5, 1 +; LMULMAX2-RV32-NEXT: or a1, a5, a1 ; LMULMAX2-RV32-NEXT: srli a5, a1, 2 ; LMULMAX2-RV32-NEXT: or a1, a1, a5 ; LMULMAX2-RV32-NEXT: srli a5, a1, 4 @@ -11237,12 +11243,13 @@ ; LMULMAX2-RV32-NEXT: vsetivli a1, 1, e64,m2,ta,mu ; LMULMAX2-RV32-NEXT: vslidedown.vi v28, v26, 2 ; LMULMAX2-RV32-NEXT: vsrl.vx v30, v28, a6 -; LMULMAX2-RV32-NEXT: vmv.x.s a1, v30 -; LMULMAX2-RV32-NEXT: vmv.x.s a5, v28 -; LMULMAX2-RV32-NEXT: bnez a1, .LBB7_8 +; LMULMAX2-RV32-NEXT: vmv.x.s a5, v30 +; LMULMAX2-RV32-NEXT: bnez a5, .LBB7_8 ; LMULMAX2-RV32-NEXT: # %bb.7: -; LMULMAX2-RV32-NEXT: srli a1, a5, 1 -; LMULMAX2-RV32-NEXT: or a1, a5, a1 +; LMULMAX2-RV32-NEXT: vsetvli zero, zero, e64,m2,ta,mu +; LMULMAX2-RV32-NEXT: vmv.x.s a1, v28 +; LMULMAX2-RV32-NEXT: srli a5, a1, 1 +; LMULMAX2-RV32-NEXT: or a1, a1, a5 ; LMULMAX2-RV32-NEXT: srli a5, a1, 2 ; LMULMAX2-RV32-NEXT: or a1, a1, a5 ; LMULMAX2-RV32-NEXT: srli a5, a1, 4 @@ -11267,8 +11274,8 @@ ; LMULMAX2-RV32-NEXT: addi a5, a1, 32 ; LMULMAX2-RV32-NEXT: j .LBB7_9 ; LMULMAX2-RV32-NEXT: .LBB7_8: -; LMULMAX2-RV32-NEXT: srli a5, a1, 1 -; LMULMAX2-RV32-NEXT: or a1, a1, a5 +; LMULMAX2-RV32-NEXT: srli a1, a5, 1 +; LMULMAX2-RV32-NEXT: or a1, a5, a1 ; LMULMAX2-RV32-NEXT: srli a5, a1, 2 ; LMULMAX2-RV32-NEXT: or a1, a1, a5 ; LMULMAX2-RV32-NEXT: srli a5, a1, 4 @@ -11295,12 +11302,13 @@ ; LMULMAX2-RV32-NEXT: vsetivli a1, 1, e64,m2,ta,mu ; LMULMAX2-RV32-NEXT: vslidedown.vi v26, v26, 1 ; LMULMAX2-RV32-NEXT: vsrl.vx v28, v26, a6 -; LMULMAX2-RV32-NEXT: vmv.x.s a1, v28 -; LMULMAX2-RV32-NEXT: vmv.x.s a5, v26 -; LMULMAX2-RV32-NEXT: bnez a1, .LBB7_11 +; LMULMAX2-RV32-NEXT: vmv.x.s a5, v28 +; LMULMAX2-RV32-NEXT: bnez a5, .LBB7_11 ; LMULMAX2-RV32-NEXT: # %bb.10: -; LMULMAX2-RV32-NEXT: srli a1, a5, 1 -; LMULMAX2-RV32-NEXT: or a1, a5, a1 +; LMULMAX2-RV32-NEXT: vsetvli zero, zero, e64,m2,ta,mu +; LMULMAX2-RV32-NEXT: vmv.x.s a1, v26 +; LMULMAX2-RV32-NEXT: srli a5, a1, 1 +; LMULMAX2-RV32-NEXT: or a1, a1, a5 ; LMULMAX2-RV32-NEXT: srli a5, a1, 2 ; LMULMAX2-RV32-NEXT: or a1, a1, a5 ; LMULMAX2-RV32-NEXT: srli a5, a1, 4 @@ -11325,8 +11333,8 @@ ; LMULMAX2-RV32-NEXT: addi a1, a1, 32 ; LMULMAX2-RV32-NEXT: j .LBB7_12 ; LMULMAX2-RV32-NEXT: .LBB7_11: -; LMULMAX2-RV32-NEXT: srli a5, a1, 1 -; LMULMAX2-RV32-NEXT: or a1, a1, a5 +; LMULMAX2-RV32-NEXT: srli a1, a5, 1 +; LMULMAX2-RV32-NEXT: or a1, a5, a1 ; LMULMAX2-RV32-NEXT: srli a5, a1, 2 ; LMULMAX2-RV32-NEXT: or a1, a1, a5 ; LMULMAX2-RV32-NEXT: srli a5, a1, 4 @@ -11544,13 +11552,14 @@ ; LMULMAX1-RV32-NEXT: addi a4, a2, 819 ; LMULMAX1-RV32-NEXT: lui a2, 61681 ; LMULMAX1-RV32-NEXT: addi t0, a2, -241 -; LMULMAX1-RV32-NEXT: lui a2, 4112 -; LMULMAX1-RV32-NEXT: addi a3, a2, 257 -; LMULMAX1-RV32-NEXT: vmv.x.s a2, v26 +; LMULMAX1-RV32-NEXT: lui a3, 4112 +; LMULMAX1-RV32-NEXT: addi a3, a3, 257 ; LMULMAX1-RV32-NEXT: bnez a1, .LBB7_2 ; LMULMAX1-RV32-NEXT: # %bb.1: -; LMULMAX1-RV32-NEXT: srli a1, a2, 1 -; LMULMAX1-RV32-NEXT: or a1, a2, a1 +; LMULMAX1-RV32-NEXT: vsetvli zero, zero, e64,m1,ta,mu +; LMULMAX1-RV32-NEXT: vmv.x.s a1, v26 +; LMULMAX1-RV32-NEXT: srli a2, a1, 1 +; LMULMAX1-RV32-NEXT: or a1, a1, a2 ; LMULMAX1-RV32-NEXT: srli a2, a1, 2 ; LMULMAX1-RV32-NEXT: or a1, a1, a2 ; LMULMAX1-RV32-NEXT: srli a2, a1, 4 @@ -11604,11 +11613,12 @@ ; LMULMAX1-RV32-NEXT: vslidedown.vi v26, v26, 1 ; LMULMAX1-RV32-NEXT: vsrl.vx v27, v26, a7 ; LMULMAX1-RV32-NEXT: vmv.x.s a1, v27 -; LMULMAX1-RV32-NEXT: vmv.x.s a2, v26 ; LMULMAX1-RV32-NEXT: bnez a1, .LBB7_5 ; LMULMAX1-RV32-NEXT: # %bb.4: -; LMULMAX1-RV32-NEXT: srli a1, a2, 1 -; LMULMAX1-RV32-NEXT: or a1, a2, a1 +; LMULMAX1-RV32-NEXT: vsetvli zero, zero, e64,m1,ta,mu +; LMULMAX1-RV32-NEXT: vmv.x.s a1, v26 +; LMULMAX1-RV32-NEXT: srli a2, a1, 1 +; LMULMAX1-RV32-NEXT: or a1, a1, a2 ; LMULMAX1-RV32-NEXT: srli a2, a1, 2 ; LMULMAX1-RV32-NEXT: or a1, a1, a2 ; LMULMAX1-RV32-NEXT: srli a2, a1, 4 @@ -11663,11 +11673,12 @@ ; LMULMAX1-RV32-NEXT: vsetivli a1, 1, e64,m1,ta,mu ; LMULMAX1-RV32-NEXT: vsrl.vx v26, v25, a7 ; LMULMAX1-RV32-NEXT: vmv.x.s a1, v26 -; LMULMAX1-RV32-NEXT: vmv.x.s a2, v25 ; LMULMAX1-RV32-NEXT: bnez a1, .LBB7_8 ; LMULMAX1-RV32-NEXT: # %bb.7: -; LMULMAX1-RV32-NEXT: srli a1, a2, 1 -; LMULMAX1-RV32-NEXT: or a1, a2, a1 +; LMULMAX1-RV32-NEXT: vsetvli zero, zero, e64,m1,ta,mu +; LMULMAX1-RV32-NEXT: vmv.x.s a1, v25 +; LMULMAX1-RV32-NEXT: srli a2, a1, 1 +; LMULMAX1-RV32-NEXT: or a1, a1, a2 ; LMULMAX1-RV32-NEXT: srli a2, a1, 2 ; LMULMAX1-RV32-NEXT: or a1, a1, a2 ; LMULMAX1-RV32-NEXT: srli a2, a1, 4 @@ -11721,11 +11732,12 @@ ; LMULMAX1-RV32-NEXT: vslidedown.vi v25, v25, 1 ; LMULMAX1-RV32-NEXT: vsrl.vx v26, v25, a7 ; LMULMAX1-RV32-NEXT: vmv.x.s a1, v26 -; LMULMAX1-RV32-NEXT: vmv.x.s a2, v25 ; LMULMAX1-RV32-NEXT: bnez a1, .LBB7_11 ; LMULMAX1-RV32-NEXT: # %bb.10: -; LMULMAX1-RV32-NEXT: srli a1, a2, 1 -; LMULMAX1-RV32-NEXT: or a1, a2, a1 +; LMULMAX1-RV32-NEXT: vsetvli zero, zero, e64,m1,ta,mu +; LMULMAX1-RV32-NEXT: vmv.x.s a1, v25 +; LMULMAX1-RV32-NEXT: srli a2, a1, 1 +; LMULMAX1-RV32-NEXT: or a1, a1, a2 ; LMULMAX1-RV32-NEXT: srli a2, a1, 2 ; LMULMAX1-RV32-NEXT: or a1, a1, a2 ; LMULMAX1-RV32-NEXT: srli a2, a1, 4 diff --git a/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-cttz.ll b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-cttz.ll --- a/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-cttz.ll +++ b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-cttz.ll @@ -2538,9 +2538,6 @@ ; LMULMAX2-RV32-NEXT: sw zero, 12(sp) ; LMULMAX2-RV32-NEXT: sw zero, 4(sp) ; LMULMAX2-RV32-NEXT: addi a6, zero, 32 -; LMULMAX2-RV32-NEXT: vsetivli a1, 1, e64,m1,ta,mu -; LMULMAX2-RV32-NEXT: vsrl.vx v26, v25, a6 -; LMULMAX2-RV32-NEXT: vmv.x.s a5, v26 ; LMULMAX2-RV32-NEXT: lui a1, 349525 ; LMULMAX2-RV32-NEXT: addi a4, a1, 1365 ; LMULMAX2-RV32-NEXT: lui a1, 209715 @@ -2548,13 +2545,16 @@ ; LMULMAX2-RV32-NEXT: lui a1, 61681 ; LMULMAX2-RV32-NEXT: addi a7, a1, -241 ; LMULMAX2-RV32-NEXT: lui a2, 4112 -; LMULMAX2-RV32-NEXT: vmv.x.s a1, v25 +; LMULMAX2-RV32-NEXT: vmv.x.s a5, v25 ; LMULMAX2-RV32-NEXT: addi a2, a2, 257 -; LMULMAX2-RV32-NEXT: bnez a1, .LBB3_2 +; LMULMAX2-RV32-NEXT: bnez a5, .LBB3_2 ; LMULMAX2-RV32-NEXT: # %bb.1: -; LMULMAX2-RV32-NEXT: addi a1, a5, -1 -; LMULMAX2-RV32-NEXT: not a5, a5 -; LMULMAX2-RV32-NEXT: and a1, a5, a1 +; LMULMAX2-RV32-NEXT: vsetivli a1, 1, e64,m1,ta,mu +; LMULMAX2-RV32-NEXT: vsrl.vx v26, v25, a6 +; LMULMAX2-RV32-NEXT: vmv.x.s a1, v26 +; LMULMAX2-RV32-NEXT: addi a5, a1, -1 +; LMULMAX2-RV32-NEXT: not a1, a1 +; LMULMAX2-RV32-NEXT: and a1, a1, a5 ; LMULMAX2-RV32-NEXT: srli a5, a1, 1 ; LMULMAX2-RV32-NEXT: and a5, a5, a4 ; LMULMAX2-RV32-NEXT: sub a1, a1, a5 @@ -2570,9 +2570,9 @@ ; LMULMAX2-RV32-NEXT: addi a5, a1, 32 ; LMULMAX2-RV32-NEXT: j .LBB3_3 ; LMULMAX2-RV32-NEXT: .LBB3_2: -; LMULMAX2-RV32-NEXT: addi a5, a1, -1 -; LMULMAX2-RV32-NEXT: not a1, a1 -; LMULMAX2-RV32-NEXT: and a1, a1, a5 +; LMULMAX2-RV32-NEXT: addi a1, a5, -1 +; LMULMAX2-RV32-NEXT: not a5, a5 +; LMULMAX2-RV32-NEXT: and a1, a5, a1 ; LMULMAX2-RV32-NEXT: srli a5, a1, 1 ; LMULMAX2-RV32-NEXT: and a5, a5, a4 ; LMULMAX2-RV32-NEXT: sub a1, a1, a5 @@ -2590,10 +2590,11 @@ ; LMULMAX2-RV32-NEXT: vsetivli a1, 1, e64,m1,ta,mu ; LMULMAX2-RV32-NEXT: vslidedown.vi v25, v25, 1 ; LMULMAX2-RV32-NEXT: vmv.x.s a5, v25 -; LMULMAX2-RV32-NEXT: vsrl.vx v25, v25, a6 -; LMULMAX2-RV32-NEXT: vmv.x.s a1, v25 ; LMULMAX2-RV32-NEXT: bnez a5, .LBB3_5 ; LMULMAX2-RV32-NEXT: # %bb.4: +; LMULMAX2-RV32-NEXT: vsetivli a1, 1, e64,m1,ta,mu +; LMULMAX2-RV32-NEXT: vsrl.vx v25, v25, a6 +; LMULMAX2-RV32-NEXT: vmv.x.s a1, v25 ; LMULMAX2-RV32-NEXT: addi a5, a1, -1 ; LMULMAX2-RV32-NEXT: not a1, a1 ; LMULMAX2-RV32-NEXT: and a1, a1, a5 @@ -2719,9 +2720,6 @@ ; LMULMAX1-RV32-NEXT: sw zero, 12(sp) ; LMULMAX1-RV32-NEXT: sw zero, 4(sp) ; LMULMAX1-RV32-NEXT: addi a6, zero, 32 -; LMULMAX1-RV32-NEXT: vsetivli a1, 1, e64,m1,ta,mu -; LMULMAX1-RV32-NEXT: vsrl.vx v26, v25, a6 -; LMULMAX1-RV32-NEXT: vmv.x.s a5, v26 ; LMULMAX1-RV32-NEXT: lui a1, 349525 ; LMULMAX1-RV32-NEXT: addi a4, a1, 1365 ; LMULMAX1-RV32-NEXT: lui a1, 209715 @@ -2729,13 +2727,16 @@ ; LMULMAX1-RV32-NEXT: lui a1, 61681 ; LMULMAX1-RV32-NEXT: addi a7, a1, -241 ; LMULMAX1-RV32-NEXT: lui a2, 4112 -; LMULMAX1-RV32-NEXT: vmv.x.s a1, v25 +; LMULMAX1-RV32-NEXT: vmv.x.s a5, v25 ; LMULMAX1-RV32-NEXT: addi a2, a2, 257 -; LMULMAX1-RV32-NEXT: bnez a1, .LBB3_2 +; LMULMAX1-RV32-NEXT: bnez a5, .LBB3_2 ; LMULMAX1-RV32-NEXT: # %bb.1: -; LMULMAX1-RV32-NEXT: addi a1, a5, -1 -; LMULMAX1-RV32-NEXT: not a5, a5 -; LMULMAX1-RV32-NEXT: and a1, a5, a1 +; LMULMAX1-RV32-NEXT: vsetivli a1, 1, e64,m1,ta,mu +; LMULMAX1-RV32-NEXT: vsrl.vx v26, v25, a6 +; LMULMAX1-RV32-NEXT: vmv.x.s a1, v26 +; LMULMAX1-RV32-NEXT: addi a5, a1, -1 +; LMULMAX1-RV32-NEXT: not a1, a1 +; LMULMAX1-RV32-NEXT: and a1, a1, a5 ; LMULMAX1-RV32-NEXT: srli a5, a1, 1 ; LMULMAX1-RV32-NEXT: and a5, a5, a4 ; LMULMAX1-RV32-NEXT: sub a1, a1, a5 @@ -2751,9 +2752,9 @@ ; LMULMAX1-RV32-NEXT: addi a5, a1, 32 ; LMULMAX1-RV32-NEXT: j .LBB3_3 ; LMULMAX1-RV32-NEXT: .LBB3_2: -; LMULMAX1-RV32-NEXT: addi a5, a1, -1 -; LMULMAX1-RV32-NEXT: not a1, a1 -; LMULMAX1-RV32-NEXT: and a1, a1, a5 +; LMULMAX1-RV32-NEXT: addi a1, a5, -1 +; LMULMAX1-RV32-NEXT: not a5, a5 +; LMULMAX1-RV32-NEXT: and a1, a5, a1 ; LMULMAX1-RV32-NEXT: srli a5, a1, 1 ; LMULMAX1-RV32-NEXT: and a5, a5, a4 ; LMULMAX1-RV32-NEXT: sub a1, a1, a5 @@ -2771,10 +2772,11 @@ ; LMULMAX1-RV32-NEXT: vsetivli a1, 1, e64,m1,ta,mu ; LMULMAX1-RV32-NEXT: vslidedown.vi v25, v25, 1 ; LMULMAX1-RV32-NEXT: vmv.x.s a5, v25 -; LMULMAX1-RV32-NEXT: vsrl.vx v25, v25, a6 -; LMULMAX1-RV32-NEXT: vmv.x.s a1, v25 ; LMULMAX1-RV32-NEXT: bnez a5, .LBB3_5 ; LMULMAX1-RV32-NEXT: # %bb.4: +; LMULMAX1-RV32-NEXT: vsetivli a1, 1, e64,m1,ta,mu +; LMULMAX1-RV32-NEXT: vsrl.vx v25, v25, a6 +; LMULMAX1-RV32-NEXT: vmv.x.s a1, v25 ; LMULMAX1-RV32-NEXT: addi a5, a1, -1 ; LMULMAX1-RV32-NEXT: not a1, a1 ; LMULMAX1-RV32-NEXT: and a1, a1, a5 @@ -7647,9 +7649,6 @@ ; LMULMAX2-RV32-NEXT: sw zero, 12(sp) ; LMULMAX2-RV32-NEXT: sw zero, 4(sp) ; LMULMAX2-RV32-NEXT: addi a6, zero, 32 -; LMULMAX2-RV32-NEXT: vsetivli a1, 1, e64,m2,ta,mu -; LMULMAX2-RV32-NEXT: vsrl.vx v28, v26, a6 -; LMULMAX2-RV32-NEXT: vmv.x.s a5, v28 ; LMULMAX2-RV32-NEXT: lui a1, 349525 ; LMULMAX2-RV32-NEXT: addi a4, a1, 1365 ; LMULMAX2-RV32-NEXT: lui a1, 209715 @@ -7657,13 +7656,16 @@ ; LMULMAX2-RV32-NEXT: lui a1, 61681 ; LMULMAX2-RV32-NEXT: addi a7, a1, -241 ; LMULMAX2-RV32-NEXT: lui a2, 4112 -; LMULMAX2-RV32-NEXT: vmv.x.s a1, v26 +; LMULMAX2-RV32-NEXT: vmv.x.s a5, v26 ; LMULMAX2-RV32-NEXT: addi a2, a2, 257 -; LMULMAX2-RV32-NEXT: bnez a1, .LBB7_2 +; LMULMAX2-RV32-NEXT: bnez a5, .LBB7_2 ; LMULMAX2-RV32-NEXT: # %bb.1: -; LMULMAX2-RV32-NEXT: addi a1, a5, -1 -; LMULMAX2-RV32-NEXT: not a5, a5 -; LMULMAX2-RV32-NEXT: and a1, a5, a1 +; LMULMAX2-RV32-NEXT: vsetivli a1, 1, e64,m2,ta,mu +; LMULMAX2-RV32-NEXT: vsrl.vx v28, v26, a6 +; LMULMAX2-RV32-NEXT: vmv.x.s a1, v28 +; LMULMAX2-RV32-NEXT: addi a5, a1, -1 +; LMULMAX2-RV32-NEXT: not a1, a1 +; LMULMAX2-RV32-NEXT: and a1, a1, a5 ; LMULMAX2-RV32-NEXT: srli a5, a1, 1 ; LMULMAX2-RV32-NEXT: and a5, a5, a4 ; LMULMAX2-RV32-NEXT: sub a1, a1, a5 @@ -7679,9 +7681,9 @@ ; LMULMAX2-RV32-NEXT: addi a5, a1, 32 ; LMULMAX2-RV32-NEXT: j .LBB7_3 ; LMULMAX2-RV32-NEXT: .LBB7_2: -; LMULMAX2-RV32-NEXT: addi a5, a1, -1 -; LMULMAX2-RV32-NEXT: not a1, a1 -; LMULMAX2-RV32-NEXT: and a1, a1, a5 +; LMULMAX2-RV32-NEXT: addi a1, a5, -1 +; LMULMAX2-RV32-NEXT: not a5, a5 +; LMULMAX2-RV32-NEXT: and a1, a5, a1 ; LMULMAX2-RV32-NEXT: srli a5, a1, 1 ; LMULMAX2-RV32-NEXT: and a5, a5, a4 ; LMULMAX2-RV32-NEXT: sub a1, a1, a5 @@ -7699,10 +7701,11 @@ ; LMULMAX2-RV32-NEXT: vsetivli a1, 1, e64,m2,ta,mu ; LMULMAX2-RV32-NEXT: vslidedown.vi v28, v26, 3 ; LMULMAX2-RV32-NEXT: vmv.x.s a5, v28 -; LMULMAX2-RV32-NEXT: vsrl.vx v28, v28, a6 -; LMULMAX2-RV32-NEXT: vmv.x.s a1, v28 ; LMULMAX2-RV32-NEXT: bnez a5, .LBB7_5 ; LMULMAX2-RV32-NEXT: # %bb.4: +; LMULMAX2-RV32-NEXT: vsetivli a1, 1, e64,m2,ta,mu +; LMULMAX2-RV32-NEXT: vsrl.vx v28, v28, a6 +; LMULMAX2-RV32-NEXT: vmv.x.s a1, v28 ; LMULMAX2-RV32-NEXT: addi a5, a1, -1 ; LMULMAX2-RV32-NEXT: not a1, a1 ; LMULMAX2-RV32-NEXT: and a1, a1, a5 @@ -7741,10 +7744,11 @@ ; LMULMAX2-RV32-NEXT: vsetivli a1, 1, e64,m2,ta,mu ; LMULMAX2-RV32-NEXT: vslidedown.vi v28, v26, 2 ; LMULMAX2-RV32-NEXT: vmv.x.s a5, v28 -; LMULMAX2-RV32-NEXT: vsrl.vx v28, v28, a6 -; LMULMAX2-RV32-NEXT: vmv.x.s a1, v28 ; LMULMAX2-RV32-NEXT: bnez a5, .LBB7_8 ; LMULMAX2-RV32-NEXT: # %bb.7: +; LMULMAX2-RV32-NEXT: vsetivli a1, 1, e64,m2,ta,mu +; LMULMAX2-RV32-NEXT: vsrl.vx v28, v28, a6 +; LMULMAX2-RV32-NEXT: vmv.x.s a1, v28 ; LMULMAX2-RV32-NEXT: addi a5, a1, -1 ; LMULMAX2-RV32-NEXT: not a1, a1 ; LMULMAX2-RV32-NEXT: and a1, a1, a5 @@ -7783,10 +7787,11 @@ ; LMULMAX2-RV32-NEXT: vsetivli a1, 1, e64,m2,ta,mu ; LMULMAX2-RV32-NEXT: vslidedown.vi v26, v26, 1 ; LMULMAX2-RV32-NEXT: vmv.x.s a5, v26 -; LMULMAX2-RV32-NEXT: vsrl.vx v26, v26, a6 -; LMULMAX2-RV32-NEXT: vmv.x.s a1, v26 ; LMULMAX2-RV32-NEXT: bnez a5, .LBB7_11 ; LMULMAX2-RV32-NEXT: # %bb.10: +; LMULMAX2-RV32-NEXT: vsetivli a1, 1, e64,m2,ta,mu +; LMULMAX2-RV32-NEXT: vsrl.vx v26, v26, a6 +; LMULMAX2-RV32-NEXT: vmv.x.s a1, v26 ; LMULMAX2-RV32-NEXT: addi a5, a1, -1 ; LMULMAX2-RV32-NEXT: not a1, a1 ; LMULMAX2-RV32-NEXT: and a1, a1, a5 @@ -7962,25 +7967,25 @@ ; LMULMAX1-RV32-NEXT: .cfi_def_cfa_offset 32 ; LMULMAX1-RV32-NEXT: vsetivli a1, 2, e64,m1,ta,mu ; LMULMAX1-RV32-NEXT: vle64.v v25, (a0) -; LMULMAX1-RV32-NEXT: addi a6, a0, 16 -; LMULMAX1-RV32-NEXT: vle64.v v26, (a6) +; LMULMAX1-RV32-NEXT: addi a7, a0, 16 +; LMULMAX1-RV32-NEXT: vle64.v v26, (a7) ; LMULMAX1-RV32-NEXT: sw zero, 28(sp) ; LMULMAX1-RV32-NEXT: sw zero, 20(sp) -; LMULMAX1-RV32-NEXT: addi a7, zero, 32 -; LMULMAX1-RV32-NEXT: vsetivli a1, 1, e64,m1,ta,mu -; LMULMAX1-RV32-NEXT: vsrl.vx v27, v26, a7 -; LMULMAX1-RV32-NEXT: vmv.x.s a1, v27 -; LMULMAX1-RV32-NEXT: lui a2, 349525 -; LMULMAX1-RV32-NEXT: addi a5, a2, 1365 -; LMULMAX1-RV32-NEXT: lui a2, 209715 -; LMULMAX1-RV32-NEXT: addi a4, a2, 819 -; LMULMAX1-RV32-NEXT: lui a2, 61681 -; LMULMAX1-RV32-NEXT: addi t0, a2, -241 +; LMULMAX1-RV32-NEXT: addi a6, zero, 32 +; LMULMAX1-RV32-NEXT: lui a1, 349525 +; LMULMAX1-RV32-NEXT: addi a5, a1, 1365 +; LMULMAX1-RV32-NEXT: lui a1, 209715 +; LMULMAX1-RV32-NEXT: addi a4, a1, 819 +; LMULMAX1-RV32-NEXT: lui a1, 61681 +; LMULMAX1-RV32-NEXT: addi t0, a1, -241 ; LMULMAX1-RV32-NEXT: lui a3, 4112 -; LMULMAX1-RV32-NEXT: vmv.x.s a2, v26 +; LMULMAX1-RV32-NEXT: vmv.x.s a1, v26 ; LMULMAX1-RV32-NEXT: addi a3, a3, 257 -; LMULMAX1-RV32-NEXT: bnez a2, .LBB7_2 +; LMULMAX1-RV32-NEXT: bnez a1, .LBB7_2 ; LMULMAX1-RV32-NEXT: # %bb.1: +; LMULMAX1-RV32-NEXT: vsetivli a1, 1, e64,m1,ta,mu +; LMULMAX1-RV32-NEXT: vsrl.vx v27, v26, a6 +; LMULMAX1-RV32-NEXT: vmv.x.s a1, v27 ; LMULMAX1-RV32-NEXT: addi a2, a1, -1 ; LMULMAX1-RV32-NEXT: not a1, a1 ; LMULMAX1-RV32-NEXT: and a1, a1, a2 @@ -7999,9 +8004,9 @@ ; LMULMAX1-RV32-NEXT: addi a1, a1, 32 ; LMULMAX1-RV32-NEXT: j .LBB7_3 ; LMULMAX1-RV32-NEXT: .LBB7_2: -; LMULMAX1-RV32-NEXT: addi a1, a2, -1 -; LMULMAX1-RV32-NEXT: not a2, a2 -; LMULMAX1-RV32-NEXT: and a1, a2, a1 +; LMULMAX1-RV32-NEXT: addi a2, a1, -1 +; LMULMAX1-RV32-NEXT: not a1, a1 +; LMULMAX1-RV32-NEXT: and a1, a1, a2 ; LMULMAX1-RV32-NEXT: srli a2, a1, 1 ; LMULMAX1-RV32-NEXT: and a2, a2, a5 ; LMULMAX1-RV32-NEXT: sub a1, a1, a2 @@ -8019,13 +8024,14 @@ ; LMULMAX1-RV32-NEXT: vsetivli a1, 1, e64,m1,ta,mu ; LMULMAX1-RV32-NEXT: vslidedown.vi v26, v26, 1 ; LMULMAX1-RV32-NEXT: vmv.x.s a1, v26 -; LMULMAX1-RV32-NEXT: vsrl.vx v26, v26, a7 -; LMULMAX1-RV32-NEXT: vmv.x.s a2, v26 ; LMULMAX1-RV32-NEXT: bnez a1, .LBB7_5 ; LMULMAX1-RV32-NEXT: # %bb.4: -; LMULMAX1-RV32-NEXT: addi a1, a2, -1 -; LMULMAX1-RV32-NEXT: not a2, a2 -; LMULMAX1-RV32-NEXT: and a1, a2, a1 +; LMULMAX1-RV32-NEXT: vsetivli a1, 1, e64,m1,ta,mu +; LMULMAX1-RV32-NEXT: vsrl.vx v26, v26, a6 +; LMULMAX1-RV32-NEXT: vmv.x.s a1, v26 +; LMULMAX1-RV32-NEXT: addi a2, a1, -1 +; LMULMAX1-RV32-NEXT: not a1, a1 +; LMULMAX1-RV32-NEXT: and a1, a1, a2 ; LMULMAX1-RV32-NEXT: srli a2, a1, 1 ; LMULMAX1-RV32-NEXT: and a2, a2, a5 ; LMULMAX1-RV32-NEXT: sub a1, a1, a2 @@ -8060,15 +8066,16 @@ ; LMULMAX1-RV32-NEXT: sw a1, 24(sp) ; LMULMAX1-RV32-NEXT: sw zero, 12(sp) ; LMULMAX1-RV32-NEXT: sw zero, 4(sp) -; LMULMAX1-RV32-NEXT: vsetivli a1, 1, e64,m1,ta,mu -; LMULMAX1-RV32-NEXT: vsrl.vx v26, v25, a7 +; LMULMAX1-RV32-NEXT: vsetvli zero, zero, e64,m1,ta,mu ; LMULMAX1-RV32-NEXT: vmv.x.s a1, v25 -; LMULMAX1-RV32-NEXT: vmv.x.s a2, v26 ; LMULMAX1-RV32-NEXT: bnez a1, .LBB7_8 ; LMULMAX1-RV32-NEXT: # %bb.7: -; LMULMAX1-RV32-NEXT: addi a1, a2, -1 -; LMULMAX1-RV32-NEXT: not a2, a2 -; LMULMAX1-RV32-NEXT: and a1, a2, a1 +; LMULMAX1-RV32-NEXT: vsetivli a1, 1, e64,m1,ta,mu +; LMULMAX1-RV32-NEXT: vsrl.vx v26, v25, a6 +; LMULMAX1-RV32-NEXT: vmv.x.s a1, v26 +; LMULMAX1-RV32-NEXT: addi a2, a1, -1 +; LMULMAX1-RV32-NEXT: not a1, a1 +; LMULMAX1-RV32-NEXT: and a1, a1, a2 ; LMULMAX1-RV32-NEXT: srli a2, a1, 1 ; LMULMAX1-RV32-NEXT: and a2, a2, a5 ; LMULMAX1-RV32-NEXT: sub a1, a1, a2 @@ -8104,13 +8111,14 @@ ; LMULMAX1-RV32-NEXT: vsetivli a1, 1, e64,m1,ta,mu ; LMULMAX1-RV32-NEXT: vslidedown.vi v25, v25, 1 ; LMULMAX1-RV32-NEXT: vmv.x.s a1, v25 -; LMULMAX1-RV32-NEXT: vsrl.vx v25, v25, a7 -; LMULMAX1-RV32-NEXT: vmv.x.s a2, v25 ; LMULMAX1-RV32-NEXT: bnez a1, .LBB7_11 ; LMULMAX1-RV32-NEXT: # %bb.10: -; LMULMAX1-RV32-NEXT: addi a1, a2, -1 -; LMULMAX1-RV32-NEXT: not a2, a2 -; LMULMAX1-RV32-NEXT: and a1, a2, a1 +; LMULMAX1-RV32-NEXT: vsetivli a1, 1, e64,m1,ta,mu +; LMULMAX1-RV32-NEXT: vsrl.vx v25, v25, a6 +; LMULMAX1-RV32-NEXT: vmv.x.s a1, v25 +; LMULMAX1-RV32-NEXT: addi a2, a1, -1 +; LMULMAX1-RV32-NEXT: not a1, a1 +; LMULMAX1-RV32-NEXT: and a1, a1, a2 ; LMULMAX1-RV32-NEXT: srli a2, a1, 1 ; LMULMAX1-RV32-NEXT: and a2, a2, a5 ; LMULMAX1-RV32-NEXT: sub a1, a1, a2 @@ -8149,7 +8157,7 @@ ; LMULMAX1-RV32-NEXT: vle32.v v26, (a1) ; LMULMAX1-RV32-NEXT: vsetivli a1, 2, e64,m1,ta,mu ; LMULMAX1-RV32-NEXT: vse64.v v25, (a0) -; LMULMAX1-RV32-NEXT: vse64.v v26, (a6) +; LMULMAX1-RV32-NEXT: vse64.v v26, (a7) ; LMULMAX1-RV32-NEXT: addi sp, sp, 32 ; LMULMAX1-RV32-NEXT: ret ; diff --git a/llvm/test/CodeGen/RISCV/rvv/frameindex-addr.ll b/llvm/test/CodeGen/RISCV/rvv/frameindex-addr.ll --- a/llvm/test/CodeGen/RISCV/rvv/frameindex-addr.ll +++ b/llvm/test/CodeGen/RISCV/rvv/frameindex-addr.ll @@ -15,8 +15,7 @@ ; CHECK: bb.0.entry: ; CHECK: liveins: $v8 ; CHECK: [[COPY:%[0-9]+]]:vr = COPY $v8 - ; CHECK: dead %2:gpr = PseudoVSETIVLI 1, 88, implicit-def $vl, implicit-def $vtype - ; CHECK: PseudoVSE64_V_M1 [[COPY]], %stack.0.a, 1, 6, implicit $vl, implicit $vtype + ; CHECK: PseudoVSE64_V_M1 [[COPY]], %stack.0.a, 1, 6 ; CHECK: [[LD:%[0-9]+]]:gpr = LD %stack.0.a, 0 :: (dereferenceable load 8 from %ir.a) ; CHECK: $x10 = COPY [[LD]] ; CHECK: PseudoRET implicit $x10 diff --git a/llvm/test/CodeGen/RISCV/rvv/mask-reg-alloc.mir b/llvm/test/CodeGen/RISCV/rvv/mask-reg-alloc.mir --- a/llvm/test/CodeGen/RISCV/rvv/mask-reg-alloc.mir +++ b/llvm/test/CodeGen/RISCV/rvv/mask-reg-alloc.mir @@ -15,20 +15,21 @@ liveins: $v0, $v1, $v2, $v3 ; CHECK-LABEL: name: mask_reg_alloc ; CHECK: liveins: $v0, $v1, $v2, $v3 - ; CHECK: renamable $v25 = PseudoVMERGE_VIM_M1 killed renamable $v2, 1, killed renamable $v0, $noreg, -1, implicit $vl, implicit $vtype + ; CHECK: dead renamable $x10 = PseudoVSETVLI $noreg, 64, implicit-def $vl, implicit-def $vtype + ; CHECK: renamable $v25 = PseudoVMERGE_VIM_M1 killed renamable $v2, 1, killed renamable $v0, $noreg, 3, implicit $vl, implicit $vtype ; CHECK: renamable $v0 = COPY killed renamable $v1 - ; CHECK: renamable $v26 = PseudoVMERGE_VIM_M1 killed renamable $v3, 1, killed renamable $v0, $noreg, -1, implicit $vl, implicit $vtype - ; CHECK: renamable $v0 = PseudoVADD_VV_M1 killed renamable $v25, killed renamable $v26, $noreg, -1, implicit $vl, implicit $vtype + ; CHECK: renamable $v26 = PseudoVMERGE_VIM_M1 killed renamable $v3, 1, killed renamable $v0, $noreg, 3, implicit $vl, implicit $vtype + ; CHECK: renamable $v0 = PseudoVADD_VV_M1 killed renamable $v25, killed renamable $v26, $noreg, 3, implicit $vl, implicit $vtype ; CHECK: PseudoRET implicit $v0 %0:vr = COPY $v0 %1:vr = COPY $v1 %2:vr = COPY $v2 %3:vr = COPY $v3 %4:vmv0 = COPY %0 - %5:vrnov0 = PseudoVMERGE_VIM_M1 killed %2, 1, %4, $noreg, -1, implicit $vl, implicit $vtype + %5:vrnov0 = PseudoVMERGE_VIM_M1 killed %2, 1, %4, $noreg, 3, implicit $vl, implicit $vtype %6:vmv0 = COPY %1 - %7:vrnov0 = PseudoVMERGE_VIM_M1 killed %3, 1, %6, $noreg, -1, implicit $vl, implicit $vtype - %8:vr = PseudoVADD_VV_M1 killed %5, killed %7, $noreg, -1, implicit $vl, implicit $vtype + %7:vrnov0 = PseudoVMERGE_VIM_M1 killed %3, 1, %6, $noreg, 3, implicit $vl, implicit $vtype + %8:vr = PseudoVADD_VV_M1 killed %5, killed %7, $noreg, 3, implicit $vl, implicit $vtype $v0 = COPY %8 PseudoRET implicit $v0 ... diff --git a/llvm/test/CodeGen/RISCV/rvv/tail-agnostic-impdef-copy.mir b/llvm/test/CodeGen/RISCV/rvv/tail-agnostic-impdef-copy.mir --- a/llvm/test/CodeGen/RISCV/rvv/tail-agnostic-impdef-copy.mir +++ b/llvm/test/CodeGen/RISCV/rvv/tail-agnostic-impdef-copy.mir @@ -52,8 +52,7 @@ ; CHECK: $v0 = COPY [[COPY]] ; CHECK: [[DEF:%[0-9]+]]:vrm8 = IMPLICIT_DEF ; CHECK: [[COPY2:%[0-9]+]]:vrm8nov0 = COPY [[DEF]] - ; CHECK: dead %5:gpr = PseudoVSETVLI $x0, 91, implicit-def $vl, implicit-def $vtype - ; CHECK: [[PseudoVLE64_V_M8_MASK:%[0-9]+]]:vrm8nov0 = PseudoVLE64_V_M8_MASK [[COPY2]], [[COPY1]], $v0, $noreg, 6, implicit $vl, implicit $vtype :: (load 64 from %ir.a, align 8) + ; CHECK: [[PseudoVLE64_V_M8_MASK:%[0-9]+]]:vrm8nov0 = PseudoVLE64_V_M8_MASK [[COPY2]], [[COPY1]], $v0, $x0, 6, implicit $vl, implicit $vtype :: (load 64 from %ir.a, align 8) ; CHECK: $v8m8 = COPY [[PseudoVLE64_V_M8_MASK]] ; CHECK: PseudoRET implicit $v8m8 %1:vr = COPY $v0