Skip to content

Commit 4bd6e15

Browse files
committed
[RISCV][GISel] Sync MaxIterations/ObserverLvl/EnableFullDCE for PreLegalizer combiners with AArch64.
1 parent 6aa7403 commit 4bd6e15

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

llvm/lib/Target/RISCV/GISel/RISCVO0PreLegalizerCombiner.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,19 @@ bool RISCVO0PreLegalizerCombiner::runOnMachineFunction(MachineFunction &MF) {
131131
CombinerInfo CInfo(/*AllowIllegalOps*/ true, /*ShouldLegalizeIllegal*/ false,
132132
/*LegalizerInfo*/ nullptr, /*EnableOpt*/ false,
133133
F.hasOptSize(), F.hasMinSize());
134+
// Disable fixed-point iteration in the Combiner. This improves compile-time
135+
// at the cost of possibly missing optimizations. See PR#94291 for details.
136+
CInfo.MaxIterations = 1;
137+
134138
RISCVO0PreLegalizerCombinerImpl Impl(MF, CInfo, &TPC, *KB,
135139
/*CSEInfo*/ nullptr, RuleConfig, ST);
136140
return Impl.combineMachineInstrs();
137141
}
138142

139143
char RISCVO0PreLegalizerCombiner::ID = 0;
140144
INITIALIZE_PASS_BEGIN(RISCVO0PreLegalizerCombiner, DEBUG_TYPE,
141-
"Combine RISC-V machine instrs before legalization", false,
142-
false)
145+
"Combine RISC-V machine instrs before legalization",
146+
false, false)
143147
INITIALIZE_PASS_DEPENDENCY(TargetPassConfig)
144148
INITIALIZE_PASS_DEPENDENCY(GISelKnownBitsAnalysis)
145149
INITIALIZE_PASS_DEPENDENCY(GISelCSEAnalysisWrapperPass)

llvm/lib/Target/RISCV/GISel/RISCVPreLegalizerCombiner.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ bool RISCVPreLegalizerCombiner::runOnMachineFunction(MachineFunction &MF) {
146146
CombinerInfo CInfo(/*AllowIllegalOps*/ true, /*ShouldLegalizeIllegal*/ false,
147147
/*LegalizerInfo*/ nullptr, EnableOpt, F.hasOptSize(),
148148
F.hasMinSize());
149+
// Disable fixed-point iteration to reduce compile-time
150+
CInfo.MaxIterations = 1;
151+
CInfo.ObserverLvl = CombinerInfo::ObserverLevel::SinglePass;
152+
// This is the first Combiner, so the input IR might contain dead
153+
// instructions.
154+
CInfo.EnableFullDCE = true;
149155
RISCVPreLegalizerCombinerImpl Impl(MF, CInfo, &TPC, *KB, CSEInfo, RuleConfig,
150156
ST, MDT, LI);
151157
return Impl.combineMachineInstrs();

0 commit comments

Comments
 (0)