Skip to content

Commit 34b10e1

Browse files
committed
[InstCombine] Remove optional LoopInfo dependency
llvm#106075 has removed the last dependency on LoopInfo in InstCombine, so don't fetch the analysis anymore and remove the use-loop-info pass option.
1 parent 5bd3ee0 commit 34b10e1

File tree

7 files changed

+12
-37
lines changed

7 files changed

+12
-37
lines changed

llvm/include/llvm/Transforms/InstCombine/InstCombine.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,12 @@ namespace llvm {
2828
static constexpr unsigned InstCombineDefaultMaxIterations = 1;
2929

3030
struct InstCombineOptions {
31-
bool UseLoopInfo = false;
3231
// Verify that a fix point has been reached after MaxIterations.
3332
bool VerifyFixpoint = false;
3433
unsigned MaxIterations = InstCombineDefaultMaxIterations;
3534

3635
InstCombineOptions() = default;
3736

38-
InstCombineOptions &setUseLoopInfo(bool Value) {
39-
UseLoopInfo = Value;
40-
return *this;
41-
}
42-
4337
InstCombineOptions &setVerifyFixpoint(bool Value) {
4438
VerifyFixpoint = Value;
4539
return *this;

llvm/include/llvm/Transforms/InstCombine/InstCombiner.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,6 @@ class LLVM_LIBRARY_VISIBILITY InstCombiner {
8080
ProfileSummaryInfo *PSI;
8181
DomConditionCache DC;
8282

83-
// Optional analyses. When non-null, these can both be used to do better
84-
// combining and will be updated to reflect any changes.
85-
LoopInfo *LI;
86-
8783
ReversePostOrderTraversal<BasicBlock *> &RPOT;
8884

8985
bool MadeIRChange = false;
@@ -106,13 +102,13 @@ class LLVM_LIBRARY_VISIBILITY InstCombiner {
106102
TargetLibraryInfo &TLI, TargetTransformInfo &TTI,
107103
DominatorTree &DT, OptimizationRemarkEmitter &ORE,
108104
BlockFrequencyInfo *BFI, BranchProbabilityInfo *BPI,
109-
ProfileSummaryInfo *PSI, const DataLayout &DL, LoopInfo *LI,
105+
ProfileSummaryInfo *PSI, const DataLayout &DL,
110106
ReversePostOrderTraversal<BasicBlock *> &RPOT)
111107
: TTI(TTI), Builder(Builder), Worklist(Worklist),
112108
MinimizeSize(MinimizeSize), AA(AA), AC(AC), TLI(TLI), DT(DT), DL(DL),
113109
SQ(DL, &TLI, &DT, &AC, nullptr, /*UseInstrInfo*/ true,
114110
/*CanUseUndef*/ true, &DC),
115-
ORE(ORE), BFI(BFI), BPI(BPI), PSI(PSI), LI(LI), RPOT(RPOT) {}
111+
ORE(ORE), BFI(BFI), BPI(BPI), PSI(PSI), RPOT(RPOT) {}
116112

117113
virtual ~InstCombiner() = default;
118114

@@ -351,7 +347,6 @@ class LLVM_LIBRARY_VISIBILITY InstCombiner {
351347
}
352348
BlockFrequencyInfo *getBlockFrequencyInfo() const { return BFI; }
353349
ProfileSummaryInfo *getProfileSummaryInfo() const { return PSI; }
354-
LoopInfo *getLoopInfo() const { return LI; }
355350

356351
// Call target specific combiners
357352
std::optional<Instruction *> targetInstCombineIntrinsic(IntrinsicInst &II);

llvm/lib/Passes/PassBuilder.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -882,9 +882,7 @@ Expected<InstCombineOptions> parseInstCombineOptions(StringRef Params) {
882882
std::tie(ParamName, Params) = Params.split(';');
883883

884884
bool Enable = !ParamName.consume_front("no-");
885-
if (ParamName == "use-loop-info") {
886-
Result.setUseLoopInfo(Enable);
887-
} else if (ParamName == "verify-fixpoint") {
885+
if (ParamName == "verify-fixpoint") {
888886
Result.setVerifyFixpoint(Enable);
889887
} else if (Enable && ParamName.consume_front("max-iterations=")) {
890888
APInt MaxIterations;

llvm/lib/Transforms/InstCombine/InstCombineInternal.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ class DataLayout;
5151
class DominatorTree;
5252
class GEPOperator;
5353
class GlobalVariable;
54-
class LoopInfo;
5554
class OptimizationRemarkEmitter;
5655
class ProfileSummaryInfo;
5756
class TargetLibraryInfo;
@@ -66,10 +65,10 @@ class LLVM_LIBRARY_VISIBILITY InstCombinerImpl final
6665
TargetLibraryInfo &TLI, TargetTransformInfo &TTI,
6766
DominatorTree &DT, OptimizationRemarkEmitter &ORE,
6867
BlockFrequencyInfo *BFI, BranchProbabilityInfo *BPI,
69-
ProfileSummaryInfo *PSI, const DataLayout &DL, LoopInfo *LI,
68+
ProfileSummaryInfo *PSI, const DataLayout &DL,
7069
ReversePostOrderTraversal<BasicBlock *> &RPOT)
7170
: InstCombiner(Worklist, Builder, MinimizeSize, AA, AC, TLI, TTI, DT, ORE,
72-
BFI, BPI, PSI, DL, LI, RPOT) {}
71+
BFI, BPI, PSI, DL, RPOT) {}
7372

7473
virtual ~InstCombinerImpl() = default;
7574

llvm/lib/Transforms/InstCombine/InstructionCombining.cpp

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
#include "llvm/Analysis/GlobalsModRef.h"
4949
#include "llvm/Analysis/InstructionSimplify.h"
5050
#include "llvm/Analysis/LazyBlockFrequencyInfo.h"
51-
#include "llvm/Analysis/LoopInfo.h"
5251
#include "llvm/Analysis/MemoryBuiltins.h"
5352
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
5453
#include "llvm/Analysis/ProfileSummaryInfo.h"
@@ -5404,7 +5403,7 @@ static bool combineInstructionsOverFunction(
54045403
Function &F, InstructionWorklist &Worklist, AliasAnalysis *AA,
54055404
AssumptionCache &AC, TargetLibraryInfo &TLI, TargetTransformInfo &TTI,
54065405
DominatorTree &DT, OptimizationRemarkEmitter &ORE, BlockFrequencyInfo *BFI,
5407-
BranchProbabilityInfo *BPI, ProfileSummaryInfo *PSI, LoopInfo *LI,
5406+
BranchProbabilityInfo *BPI, ProfileSummaryInfo *PSI,
54085407
const InstCombineOptions &Opts) {
54095408
auto &DL = F.getDataLayout();
54105409

@@ -5443,7 +5442,7 @@ static bool combineInstructionsOverFunction(
54435442
<< F.getName() << "\n");
54445443

54455444
InstCombinerImpl IC(Worklist, Builder, F.hasMinSize(), AA, AC, TLI, TTI, DT,
5446-
ORE, BFI, BPI, PSI, DL, LI, RPOT);
5445+
ORE, BFI, BPI, PSI, DL, RPOT);
54475446
IC.MaxArraySizeForCombine = MaxArraySize;
54485447
bool MadeChangeInThisIteration = IC.prepareWorklist(F);
54495448
MadeChangeInThisIteration |= IC.run();
@@ -5480,7 +5479,6 @@ void InstCombinePass::printPipeline(
54805479
OS, MapClassName2PassName);
54815480
OS << '<';
54825481
OS << "max-iterations=" << Options.MaxIterations << ";";
5483-
OS << (Options.UseLoopInfo ? "" : "no-") << "use-loop-info;";
54845482
OS << (Options.VerifyFixpoint ? "" : "no-") << "verify-fixpoint";
54855483
OS << '>';
54865484
}
@@ -5493,12 +5491,6 @@ PreservedAnalyses InstCombinePass::run(Function &F,
54935491
auto &ORE = AM.getResult<OptimizationRemarkEmitterAnalysis>(F);
54945492
auto &TTI = AM.getResult<TargetIRAnalysis>(F);
54955493

5496-
// TODO: Only use LoopInfo when the option is set. This requires that the
5497-
// callers in the pass pipeline explicitly set the option.
5498-
auto *LI = AM.getCachedResult<LoopAnalysis>(F);
5499-
if (!LI && Options.UseLoopInfo)
5500-
LI = &AM.getResult<LoopAnalysis>(F);
5501-
55025494
auto *AA = &AM.getResult<AAManager>(F);
55035495
auto &MAMProxy = AM.getResult<ModuleAnalysisManagerFunctionProxy>(F);
55045496
ProfileSummaryInfo *PSI =
@@ -5508,7 +5500,7 @@ PreservedAnalyses InstCombinePass::run(Function &F,
55085500
auto *BPI = AM.getCachedResult<BranchProbabilityAnalysis>(F);
55095501

55105502
if (!combineInstructionsOverFunction(F, Worklist, AA, AC, TLI, TTI, DT, ORE,
5511-
BFI, BPI, PSI, LI, Options))
5503+
BFI, BPI, PSI, Options))
55125504
// No changes, all analyses are preserved.
55135505
return PreservedAnalyses::all();
55145506

@@ -5547,8 +5539,6 @@ bool InstructionCombiningPass::runOnFunction(Function &F) {
55475539
auto &ORE = getAnalysis<OptimizationRemarkEmitterWrapperPass>().getORE();
55485540

55495541
// Optional analyses.
5550-
auto *LIWP = getAnalysisIfAvailable<LoopInfoWrapperPass>();
5551-
auto *LI = LIWP ? &LIWP->getLoopInfo() : nullptr;
55525542
ProfileSummaryInfo *PSI =
55535543
&getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
55545544
BlockFrequencyInfo *BFI =
@@ -5561,8 +5551,7 @@ bool InstructionCombiningPass::runOnFunction(Function &F) {
55615551
BPI = &WrapperPass->getBPI();
55625552

55635553
return combineInstructionsOverFunction(F, Worklist, AA, AC, TLI, TTI, DT, ORE,
5564-
BFI, BPI, PSI, LI,
5565-
InstCombineOptions());
5554+
BFI, BPI, PSI, InstCombineOptions());
55665555
}
55675556

55685557
char InstructionCombiningPass::ID = 0;

llvm/test/Other/new-pm-print-pipeline.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@
9292
; CHECK-27: function(separate-const-offset-from-gep<lower-gep>)
9393

9494
;; Test InstCombine options - the first pass checks default settings, and the second checks customized options.
95-
; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='function(instcombine,instcombine<use-loop-info;no-verify-fixpoint;max-iterations=42>)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-28
96-
; CHECK-28: function(instcombine<max-iterations=1;no-use-loop-info;verify-fixpoint>,instcombine<max-iterations=42;use-loop-info;no-verify-fixpoint>)
95+
; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='function(instcombine,instcombine<no-verify-fixpoint;max-iterations=42>)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-28
96+
; CHECK-28: function(instcombine<max-iterations=1;verify-fixpoint>,instcombine<max-iterations=42;no-verify-fixpoint>)
9797

9898
;; Test function-attrs
9999
; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='cgscc(function-attrs<skip-non-recursive-function-attrs>)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-29

llvm/test/Transforms/InstCombine/gep-combine-loop-invariant.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2-
; RUN: opt < %s -passes='instcombine<use-loop-info>' -S | FileCheck %s
2+
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
33

44
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
55
target triple = "x86_64-unknown-linux-gnu"

0 commit comments

Comments
 (0)