Skip to content

Commit b5ce483

Browse files
committed
[RISCV] Remove support for pre-RA vsetvli insertion
Now that LLVM 19.1.1 has been out for a while with post-vector-RA vsetvli insertion enabled by default, this proposes to remove the flag that restores the old pre-RA behaviour so we only have one configuration going forward. That flag was mainly meant as a fallback in case users ran into issues, but I haven't seen anything reported so far.
1 parent 496187b commit b5ce483

File tree

3 files changed

+133
-366
lines changed

3 files changed

+133
-366
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfo.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,17 +179,10 @@ bool RISCVInstrInfo::isReallyTriviallyReMaterializable(
179179
case RISCV::VMV_S_X:
180180
case RISCV::VFMV_S_F:
181181
case RISCV::VID_V:
182-
if (MI.getOperand(1).isUndef() &&
183-
/* After RISCVInsertVSETVLI most pseudos will have implicit uses on vl
184-
and vtype. Make sure we only rematerialize before RISCVInsertVSETVLI
185-
i.e. -riscv-vsetvl-after-rvv-regalloc=true */
186-
!MI.hasRegisterImplicitUseOperand(RISCV::VTYPE))
187-
return true;
188-
break;
182+
return MI.getOperand(1).isUndef();
189183
default:
190-
break;
184+
return TargetInstrInfo::isReallyTriviallyReMaterializable(MI);
191185
}
192-
return TargetInstrInfo::isReallyTriviallyReMaterializable(MI);
193186
}
194187

195188
static bool forwardCopyWillClobberTuple(unsigned DstReg, unsigned SrcReg,

llvm/lib/Target/RISCV/RISCVTargetMachine.cpp

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,6 @@ static cl::opt<bool> EnableMISchedLoadClustering(
9999
cl::desc("Enable load clustering in the machine scheduler"),
100100
cl::init(true));
101101

102-
static cl::opt<bool> EnableVSETVLIAfterRVVRegAlloc(
103-
"riscv-vsetvl-after-rvv-regalloc", cl::Hidden,
104-
cl::desc("Insert vsetvls after vector register allocation"),
105-
cl::init(true));
106-
107102
extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeRISCVTarget() {
108103
RegisterTargetMachine<RISCVTargetMachine> X(getTheRISCV32Target());
109104
RegisterTargetMachine<RISCVTargetMachine> Y(getTheRISCV64Target());
@@ -405,8 +400,7 @@ FunctionPass *RISCVPassConfig::createRVVRegAllocPass(bool Optimized) {
405400

406401
bool RISCVPassConfig::addRegAssignAndRewriteFast() {
407402
addPass(createRVVRegAllocPass(false));
408-
if (EnableVSETVLIAfterRVVRegAlloc)
409-
addPass(createRISCVInsertVSETVLIPass());
403+
addPass(createRISCVInsertVSETVLIPass());
410404
if (TM->getOptLevel() != CodeGenOptLevel::None &&
411405
EnableRISCVDeadRegisterElimination)
412406
addPass(createRISCVDeadRegisterDefinitionsPass());
@@ -416,8 +410,7 @@ bool RISCVPassConfig::addRegAssignAndRewriteFast() {
416410
bool RISCVPassConfig::addRegAssignAndRewriteOptimized() {
417411
addPass(createRVVRegAllocPass(true));
418412
addPass(createVirtRegRewriter(false));
419-
if (EnableVSETVLIAfterRVVRegAlloc)
420-
addPass(createRISCVInsertVSETVLIPass());
413+
addPass(createRISCVInsertVSETVLIPass());
421414
if (TM->getOptLevel() != CodeGenOptLevel::None &&
422415
EnableRISCVDeadRegisterElimination)
423416
addPass(createRISCVDeadRegisterDefinitionsPass());
@@ -564,15 +557,6 @@ void RISCVPassConfig::addPreRegAlloc() {
564557
addPass(createRISCVInsertReadWriteCSRPass());
565558
addPass(createRISCVInsertWriteVXRMPass());
566559
addPass(createRISCVLandingPadSetupPass());
567-
568-
// Run RISCVInsertVSETVLI after PHI elimination. On O1 and above do it after
569-
// register coalescing so needVSETVLIPHI doesn't need to look through COPYs.
570-
if (!EnableVSETVLIAfterRVVRegAlloc) {
571-
if (TM->getOptLevel() == CodeGenOptLevel::None)
572-
insertPass(&PHIEliminationID, &RISCVInsertVSETVLIID);
573-
else
574-
insertPass(&RegisterCoalescerID, &RISCVInsertVSETVLIID);
575-
}
576560
}
577561

578562
void RISCVPassConfig::addFastRegAlloc() {

0 commit comments

Comments
 (0)