Skip to content

Commit 194a407

Browse files
author
Fedor Sergeev
committedMar 15, 2018
[New PM][IRCE] port of Inductive Range Check Elimination pass to the new pass manager
There are two nontrivial details here: * Loop structure update interface is quite different with new pass manager, so the code to add new loops was factored out * BranchProbabilityInfo is not a loop analysis, so it can not be just getResult'ed from within the loop pass. It cant even be queried through getCachedResult as LoopCanonicalization sequence (e.g. LoopSimplify) might invalidate BPI results. Complete solution for BPI will likely take some time to discuss and figure out, so for now this was partially solved by making BPI optional in IRCE (skipping a couple of profitability checks if it is absent). Most of the IRCE tests got their corresponding new-pass-manager variant enabled. Only two of them depend on BPI, both marked with TODO, to be turned on when BPI starts being available for loop passes. Reviewers: chandlerc, mkazantsev, sanjoy, asbirlea Reviewed By: mkazantsev Differential Revision: https://reviews.llvm.org/D43795 llvm-svn: 327619
1 parent 5704dc0 commit 194a407

33 files changed

+155
-42
lines changed
 

‎llvm/include/llvm/InitializePasses.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ void initializeIfConverterPass(PassRegistry&);
166166
void initializeImplicitNullChecksPass(PassRegistry&);
167167
void initializeIndVarSimplifyLegacyPassPass(PassRegistry&);
168168
void initializeIndirectBrExpandPassPass(PassRegistry&);
169-
void initializeInductiveRangeCheckEliminationPass(PassRegistry&);
169+
void initializeIRCELegacyPassPass(PassRegistry&);
170170
void initializeInferAddressSpacesPass(PassRegistry&);
171171
void initializeInferFunctionAttrsLegacyPassPass(PassRegistry&);
172172
void initializeInlineCostAnalysisPass(PassRegistry&);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//===- InductiveRangeCheckElimination.h - IRCE ------------------*- C++ -*-===//
2+
//
3+
// The LLVM Compiler Infrastructure
4+
//
5+
// This file is distributed under the University of Illinois Open Source
6+
// License. See LICENSE.TXT for details.
7+
//
8+
//===----------------------------------------------------------------------===//
9+
//
10+
// This file provides the interface for the Inductive Range Check Elimination
11+
// loop pass.
12+
//
13+
//===----------------------------------------------------------------------===//
14+
15+
#ifndef LLVM_TRANSFORMS_SCALAR_INDUCTIVERANGECHECKELIMINATION_H
16+
#define LLVM_TRANSFORMS_SCALAR_INDUCTIVERANGECHECKELIMINATION_H
17+
18+
#include "llvm/IR/PassManager.h"
19+
#include "llvm/Transforms/Scalar/LoopPassManager.h"
20+
21+
namespace llvm {
22+
23+
class IRCEPass : public PassInfoMixin<IRCEPass> {
24+
public:
25+
PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
26+
LoopStandardAnalysisResults &AR, LPMUpdater &U);
27+
};
28+
29+
} // end namespace llvm
30+
31+
#endif // LLVM_TRANSFORMS_SCALAR_INDUCTIVERANGECHECKELIMINATION_H

‎llvm/lib/Passes/PassBuilder.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
#include "llvm/Transforms/Scalar/GuardWidening.h"
104104
#include "llvm/Transforms/Scalar/IVUsersPrinter.h"
105105
#include "llvm/Transforms/Scalar/IndVarSimplify.h"
106+
#include "llvm/Transforms/Scalar/InductiveRangeCheckElimination.h"
106107
#include "llvm/Transforms/Scalar/JumpThreading.h"
107108
#include "llvm/Transforms/Scalar/LICM.h"
108109
#include "llvm/Transforms/Scalar/LoopAccessAnalysisPrinter.h"

‎llvm/lib/Passes/PassRegistry.def

+1
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ LOOP_PASS("loop-deletion", LoopDeletionPass())
237237
LOOP_PASS("simplify-cfg", LoopSimplifyCFGPass())
238238
LOOP_PASS("strength-reduce", LoopStrengthReducePass())
239239
LOOP_PASS("indvars", IndVarSimplifyPass())
240+
LOOP_PASS("irce", IRCEPass())
240241
LOOP_PASS("unroll-full", LoopFullUnrollPass())
241242
LOOP_PASS("unswitch", SimpleLoopUnswitchPass())
242243
LOOP_PASS("print-access-info", LoopAccessInfoPrinterPass(dbgs()))

‎llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp

+88-39
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
//
4444
//===----------------------------------------------------------------------===//
4545

46+
#include "llvm/Transforms/Scalar/InductiveRangeCheckElimination.h"
4647
#include "llvm/ADT/APInt.h"
4748
#include "llvm/ADT/ArrayRef.h"
4849
#include "llvm/ADT/None.h"
@@ -52,6 +53,7 @@
5253
#include "llvm/ADT/StringRef.h"
5354
#include "llvm/ADT/Twine.h"
5455
#include "llvm/Analysis/BranchProbabilityInfo.h"
56+
#include "llvm/Analysis/LoopAnalysisManager.h"
5557
#include "llvm/Analysis/LoopInfo.h"
5658
#include "llvm/Analysis/LoopPass.h"
5759
#include "llvm/Analysis/ScalarEvolution.h"
@@ -235,17 +237,31 @@ class InductiveRangeCheck {
235237
/// checks, and hence don't end up in \p Checks.
236238
static void
237239
extractRangeChecksFromBranch(BranchInst *BI, Loop *L, ScalarEvolution &SE,
238-
BranchProbabilityInfo &BPI,
240+
BranchProbabilityInfo *BPI,
239241
SmallVectorImpl<InductiveRangeCheck> &Checks);
240242
};
241243

242-
class InductiveRangeCheckElimination : public LoopPass {
244+
class InductiveRangeCheckElimination {
245+
ScalarEvolution &SE;
246+
BranchProbabilityInfo *BPI;
247+
DominatorTree &DT;
248+
LoopInfo &LI;
249+
250+
public:
251+
InductiveRangeCheckElimination(ScalarEvolution &SE,
252+
BranchProbabilityInfo *BPI, DominatorTree &DT,
253+
LoopInfo &LI)
254+
: SE(SE), BPI(BPI), DT(DT), LI(LI) {}
255+
256+
bool run(Loop *L, function_ref<void(Loop *, bool)> LPMAddNewLoop);
257+
};
258+
259+
class IRCELegacyPass : public LoopPass {
243260
public:
244261
static char ID;
245262

246-
InductiveRangeCheckElimination() : LoopPass(ID) {
247-
initializeInductiveRangeCheckEliminationPass(
248-
*PassRegistry::getPassRegistry());
263+
IRCELegacyPass() : LoopPass(ID) {
264+
initializeIRCELegacyPassPass(*PassRegistry::getPassRegistry());
249265
}
250266

251267
void getAnalysisUsage(AnalysisUsage &AU) const override {
@@ -258,14 +274,14 @@ class InductiveRangeCheckElimination : public LoopPass {
258274

259275
} // end anonymous namespace
260276

261-
char InductiveRangeCheckElimination::ID = 0;
277+
char IRCELegacyPass::ID = 0;
262278

263-
INITIALIZE_PASS_BEGIN(InductiveRangeCheckElimination, "irce",
279+
INITIALIZE_PASS_BEGIN(IRCELegacyPass, "irce",
264280
"Inductive range check elimination", false, false)
265281
INITIALIZE_PASS_DEPENDENCY(BranchProbabilityInfoWrapperPass)
266282
INITIALIZE_PASS_DEPENDENCY(LoopPass)
267-
INITIALIZE_PASS_END(InductiveRangeCheckElimination, "irce",
268-
"Inductive range check elimination", false, false)
283+
INITIALIZE_PASS_END(IRCELegacyPass, "irce", "Inductive range check elimination",
284+
false, false)
269285

270286
StringRef InductiveRangeCheck::rangeCheckKindToStr(
271287
InductiveRangeCheck::RangeCheckKind RCK) {
@@ -417,15 +433,15 @@ void InductiveRangeCheck::extractRangeChecksFromCond(
417433
}
418434

419435
void InductiveRangeCheck::extractRangeChecksFromBranch(
420-
BranchInst *BI, Loop *L, ScalarEvolution &SE, BranchProbabilityInfo &BPI,
436+
BranchInst *BI, Loop *L, ScalarEvolution &SE, BranchProbabilityInfo *BPI,
421437
SmallVectorImpl<InductiveRangeCheck> &Checks) {
422438
if (BI->isUnconditional() || BI->getParent() == L->getLoopLatch())
423439
return;
424440

425441
BranchProbability LikelyTaken(15, 16);
426442

427-
if (!SkipProfitabilityChecks &&
428-
BPI.getEdgeProbability(BI->getParent(), (unsigned)0) < LikelyTaken)
443+
if (!SkipProfitabilityChecks && BPI &&
444+
BPI->getEdgeProbability(BI->getParent(), (unsigned)0) < LikelyTaken)
429445
return;
430446

431447
SmallPtrSet<Value *, 8> Visited;
@@ -516,9 +532,8 @@ struct LoopStructure {
516532
}
517533

518534
static Optional<LoopStructure> parseLoopStructure(ScalarEvolution &,
519-
BranchProbabilityInfo &BPI,
520-
Loop &,
521-
const char *&);
535+
BranchProbabilityInfo *BPI,
536+
Loop &, const char *&);
522537
};
523538

524539
/// This class is used to constrain loops to run within a given iteration space.
@@ -585,7 +600,7 @@ class LoopConstrainer {
585600
// Create the appropriate loop structure needed to describe a cloned copy of
586601
// `Original`. The clone is described by `VM`.
587602
Loop *createClonedLoopStructure(Loop *Original, Loop *Parent,
588-
ValueToValueMapTy &VM);
603+
ValueToValueMapTy &VM, bool IsSubloop);
589604

590605
// Rewrite the iteration space of the loop denoted by (LS, Preheader). The
591606
// iteration space of the rewritten loop ends at ExitLoopAt. The start of the
@@ -637,8 +652,8 @@ class LoopConstrainer {
637652
LLVMContext &Ctx;
638653
ScalarEvolution &SE;
639654
DominatorTree &DT;
640-
LPPassManager &LPM;
641655
LoopInfo &LI;
656+
function_ref<void(Loop *, bool)> LPMAddNewLoop;
642657

643658
// Information about the original loop we started out with.
644659
Loop &OriginalLoop;
@@ -658,12 +673,13 @@ class LoopConstrainer {
658673
LoopStructure MainLoopStructure;
659674

660675
public:
661-
LoopConstrainer(Loop &L, LoopInfo &LI, LPPassManager &LPM,
676+
LoopConstrainer(Loop &L, LoopInfo &LI,
677+
function_ref<void(Loop *, bool)> LPMAddNewLoop,
662678
const LoopStructure &LS, ScalarEvolution &SE,
663679
DominatorTree &DT, InductiveRangeCheck::Range R)
664680
: F(*L.getHeader()->getParent()), Ctx(L.getHeader()->getContext()),
665-
SE(SE), DT(DT), LPM(LPM), LI(LI), OriginalLoop(L), Range(R),
666-
MainLoopStructure(LS) {}
681+
SE(SE), DT(DT), LI(LI), LPMAddNewLoop(LPMAddNewLoop), OriginalLoop(L),
682+
Range(R), MainLoopStructure(LS) {}
667683

668684
// Entry point for the algorithm. Returns true on success.
669685
bool run();
@@ -726,8 +742,8 @@ static bool SumCanReachMin(ScalarEvolution &SE, const SCEV *S1, const SCEV *S2,
726742

727743
Optional<LoopStructure>
728744
LoopStructure::parseLoopStructure(ScalarEvolution &SE,
729-
BranchProbabilityInfo &BPI,
730-
Loop &L, const char *&FailureReason) {
745+
BranchProbabilityInfo *BPI, Loop &L,
746+
const char *&FailureReason) {
731747
if (!L.isLoopSimplifyForm()) {
732748
FailureReason = "loop not in LoopSimplify form";
733749
return None;
@@ -762,7 +778,8 @@ LoopStructure::parseLoopStructure(ScalarEvolution &SE,
762778
unsigned LatchBrExitIdx = LatchBr->getSuccessor(0) == Header ? 1 : 0;
763779

764780
BranchProbability ExitProbability =
765-
BPI.getEdgeProbability(LatchBr->getParent(), LatchBrExitIdx);
781+
BPI ? BPI->getEdgeProbability(LatchBr->getParent(), LatchBrExitIdx)
782+
: BranchProbability::getZero();
766783

767784
if (!SkipProfitabilityChecks &&
768785
ExitProbability > BranchProbability(1, MaxExitProbReciprocal)) {
@@ -1396,13 +1413,14 @@ void LoopConstrainer::addToParentLoopIfNeeded(ArrayRef<BasicBlock *> BBs) {
13961413
}
13971414

13981415
Loop *LoopConstrainer::createClonedLoopStructure(Loop *Original, Loop *Parent,
1399-
ValueToValueMapTy &VM) {
1416+
ValueToValueMapTy &VM,
1417+
bool IsSubloop) {
14001418
Loop &New = *LI.AllocateLoop();
14011419
if (Parent)
14021420
Parent->addChildLoop(&New);
14031421
else
14041422
LI.addTopLevelLoop(&New);
1405-
LPM.addLoop(New);
1423+
LPMAddNewLoop(&New, IsSubloop);
14061424

14071425
// Add all of the blocks in Original to the new loop.
14081426
for (auto *BB : Original->blocks())
@@ -1411,7 +1429,7 @@ Loop *LoopConstrainer::createClonedLoopStructure(Loop *Original, Loop *Parent,
14111429

14121430
// Add all of the subloops to the new loop.
14131431
for (Loop *SubLoop : *Original)
1414-
createClonedLoopStructure(SubLoop, &New, VM);
1432+
createClonedLoopStructure(SubLoop, &New, VM, /* IsSubloop */ true);
14151433

14161434
return &New;
14171435
}
@@ -1561,13 +1579,15 @@ bool LoopConstrainer::run() {
15611579
// LI when LoopSimplifyForm is generated.
15621580
Loop *PreL = nullptr, *PostL = nullptr;
15631581
if (!PreLoop.Blocks.empty()) {
1564-
PreL = createClonedLoopStructure(
1565-
&OriginalLoop, OriginalLoop.getParentLoop(), PreLoop.Map);
1582+
PreL = createClonedLoopStructure(&OriginalLoop,
1583+
OriginalLoop.getParentLoop(), PreLoop.Map,
1584+
/* IsSubLoop */ false);
15661585
}
15671586

15681587
if (!PostLoop.Blocks.empty()) {
1569-
PostL = createClonedLoopStructure(
1570-
&OriginalLoop, OriginalLoop.getParentLoop(), PostLoop.Map);
1588+
PostL =
1589+
createClonedLoopStructure(&OriginalLoop, OriginalLoop.getParentLoop(),
1590+
PostLoop.Map, /* IsSubLoop */ false);
15711591
}
15721592

15731593
// This function canonicalizes the loop into Loop-Simplify and LCSSA forms.
@@ -1738,12 +1758,45 @@ IntersectUnsignedRange(ScalarEvolution &SE,
17381758
return Ret;
17391759
}
17401760

1741-
bool InductiveRangeCheckElimination::runOnLoop(Loop *L, LPPassManager &LPM) {
1761+
PreservedAnalyses IRCEPass::run(Loop &L, LoopAnalysisManager &AM,
1762+
LoopStandardAnalysisResults &AR,
1763+
LPMUpdater &U) {
1764+
Function *F = L.getHeader()->getParent();
1765+
const auto &FAM =
1766+
AM.getResult<FunctionAnalysisManagerLoopProxy>(L, AR).getManager();
1767+
auto *BPI = FAM.getCachedResult<BranchProbabilityAnalysis>(*F);
1768+
InductiveRangeCheckElimination IRCE(AR.SE, BPI, AR.DT, AR.LI);
1769+
auto LPMAddNewLoop = [&U](Loop *NL, bool IsSubloop) {
1770+
if (!IsSubloop)
1771+
U.addSiblingLoops(NL);
1772+
};
1773+
bool Changed = IRCE.run(&L, LPMAddNewLoop);
1774+
if (!Changed)
1775+
return PreservedAnalyses::all();
1776+
1777+
return getLoopPassPreservedAnalyses();
1778+
}
1779+
1780+
bool IRCELegacyPass::runOnLoop(Loop *L, LPPassManager &LPM) {
17421781
if (skipLoop(L))
17431782
return false;
17441783

1784+
ScalarEvolution &SE = getAnalysis<ScalarEvolutionWrapperPass>().getSE();
1785+
BranchProbabilityInfo &BPI =
1786+
getAnalysis<BranchProbabilityInfoWrapperPass>().getBPI();
1787+
auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
1788+
auto &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
1789+
InductiveRangeCheckElimination IRCE(SE, &BPI, DT, LI);
1790+
auto LPMAddNewLoop = [&LPM](Loop *NL, bool /* IsSubLoop */) {
1791+
LPM.addLoop(*NL);
1792+
};
1793+
return IRCE.run(L, LPMAddNewLoop);
1794+
}
1795+
1796+
bool InductiveRangeCheckElimination::run(
1797+
Loop *L, function_ref<void(Loop *, bool)> LPMAddNewLoop) {
17451798
if (L->getBlocks().size() >= LoopSizeCutoff) {
1746-
DEBUG(dbgs() << "irce: giving up constraining loop, too large\n";);
1799+
DEBUG(dbgs() << "irce: giving up constraining loop, too large\n");
17471800
return false;
17481801
}
17491802

@@ -1755,9 +1808,6 @@ bool InductiveRangeCheckElimination::runOnLoop(Loop *L, LPPassManager &LPM) {
17551808

17561809
LLVMContext &Context = Preheader->getContext();
17571810
SmallVector<InductiveRangeCheck, 16> RangeChecks;
1758-
ScalarEvolution &SE = getAnalysis<ScalarEvolutionWrapperPass>().getSE();
1759-
BranchProbabilityInfo &BPI =
1760-
getAnalysis<BranchProbabilityInfoWrapperPass>().getBPI();
17611811

17621812
for (auto BBI : L->getBlocks())
17631813
if (BranchInst *TBI = dyn_cast<BranchInst>(BBI->getTerminator()))
@@ -1823,9 +1873,8 @@ bool InductiveRangeCheckElimination::runOnLoop(Loop *L, LPPassManager &LPM) {
18231873
if (!SafeIterRange.hasValue())
18241874
return false;
18251875

1826-
auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
1827-
LoopConstrainer LC(*L, getAnalysis<LoopInfoWrapperPass>().getLoopInfo(), LPM,
1828-
LS, SE, DT, SafeIterRange.getValue());
1876+
LoopConstrainer LC(*L, LI, LPMAddNewLoop, LS, SE, DT,
1877+
SafeIterRange.getValue());
18291878
bool Changed = LC.run();
18301879

18311880
if (Changed) {
@@ -1855,5 +1904,5 @@ bool InductiveRangeCheckElimination::runOnLoop(Loop *L, LPPassManager &LPM) {
18551904
}
18561905

18571906
Pass *llvm::createInductiveRangeCheckEliminationPass() {
1858-
return new InductiveRangeCheckElimination;
1907+
return new IRCELegacyPass();
18591908
}

‎llvm/lib/Transforms/Scalar/Scalar.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void llvm::initializeScalarOpts(PassRegistry &Registry) {
5252
initializeGVNHoistLegacyPassPass(Registry);
5353
initializeGVNSinkLegacyPassPass(Registry);
5454
initializeFlattenCFGPassPass(Registry);
55-
initializeInductiveRangeCheckEliminationPass(Registry);
55+
initializeIRCELegacyPassPass(Registry);
5656
initializeIndVarSimplifyLegacyPassPass(Registry);
5757
initializeInferAddressSpacesPass(Registry);
5858
initializeJumpThreadingPass(Registry);

‎llvm/test/Transforms/IRCE/add-metadata-pre-post-loops.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: opt -irce -S < %s 2>&1 | FileCheck %s
2+
; RUN: opt -passes='require<branch-prob>,loop(irce)' -S < %s 2>&1 | FileCheck %s
23

34
; test that the pre and post loops have loop metadata which disables any further
45
; loop optimizations.

‎llvm/test/Transforms/IRCE/bad-loop-structure.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: opt -S -irce -irce-print-changed-loops=true < %s | FileCheck %s
2+
; RUN: opt -S -passes='require<branch-prob>,loop(irce)' -irce-print-changed-loops=true < %s | FileCheck %s
23

34
; CHECK-NOT: irce
45

‎llvm/test/Transforms/IRCE/bad_expander.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: opt -verify-loop-info -irce-print-changed-loops -irce -S < %s 2>&1 | FileCheck %s
2+
; RUN: opt -verify-loop-info -irce-print-changed-loops -passes='require<branch-prob>,loop(irce)' -S < %s 2>&1 | FileCheck %s
23

34
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128-ni:1"
45
target triple = "x86_64-unknown-linux-gnu"

‎llvm/test/Transforms/IRCE/bug-loop-varying-upper-limit.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: opt -irce-print-changed-loops -S -verify-loop-info -irce -verify < %s 2>&1 | FileCheck %s
2+
; RUN: opt -irce-print-changed-loops -S -verify-loop-info -passes='require<branch-prob>,loop(irce)' -verify < %s 2>&1 | FileCheck %s
23

34
; CHECK-NOT: constrained loop
45

‎llvm/test/Transforms/IRCE/bug-mismatched-types.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: opt -verify-loop-info -irce -S < %s
2+
; RUN: opt -verify-loop-info -passes='require<branch-prob>,loop(irce)' -S < %s
23

34
; These test cases don't check the correctness of the transform, but
45
; that -irce does not crash in the presence of certain things in

‎llvm/test/Transforms/IRCE/clamp.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: opt -verify-loop-info -irce-print-changed-loops -irce -S < %s 2>&1 | FileCheck %s
2+
; RUN: opt -verify-loop-info -irce-print-changed-loops -passes='require<branch-prob>,loop(irce)' -S < %s 2>&1 | FileCheck %s
23

34
; The test demonstrates that incorrect behavior of Clamp may lead to incorrect
45
; calculation of post-loop exit condition.

‎llvm/test/Transforms/IRCE/conjunctive-checks.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: opt -S -verify-loop-info -irce < %s | FileCheck %s
2+
; RUN: opt -S -verify-loop-info -passes='require<branch-prob>,loop(irce)' < %s | FileCheck %s
23

34
define void @f_0(i32 *%arr, i32 *%a_len_ptr, i32 %n, i1* %cond_buf) {
45
; CHECK-LABEL: @f_0(

‎llvm/test/Transforms/IRCE/correct-loop-info.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
22
; RUN: opt -irce < %s -S | FileCheck %s
3+
; RUN: opt -passes='require<branch-prob>,loop(irce)' < %s -S | FileCheck %s
34

45
; REQUIRES: asserts
56

‎llvm/test/Transforms/IRCE/decrementing-loop.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: opt -verify-loop-info -irce -S < %s | FileCheck %s
2+
; RUN: opt -verify-loop-info -passes='require<branch-prob>,loop(irce)' -S < %s | FileCheck %s
23

34
define void @decrementing_loop(i32 *%arr, i32 *%a_len_ptr, i32 %n) {
45
entry:

‎llvm/test/Transforms/IRCE/empty_ranges.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: opt -verify-loop-info -irce-print-changed-loops -irce -S
2+
; RUN: opt -verify-loop-info -irce-print-changed-loops -passes='require<branch-prob>,loop(irce)' -S
23

34
; Make sure that IRCE doesn't apply in case of empty ranges.
45
; (i + 30 < 40) if i in [-30, 10).

‎llvm/test/Transforms/IRCE/eq_ne.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: opt -verify-loop-info -irce-print-changed-loops -irce -S < %s 2>&1 | FileCheck %s
2+
; RUN: opt -verify-loop-info -irce-print-changed-loops -passes='require<branch-prob>,loop(irce)' -S < %s 2>&1 | FileCheck %s
23

34
; CHECK: irce: in function test_01: constrained Loop at depth 1 containing: %loop<header><exiting>,%in.bounds<latch><exiting>
45
; CHECK: irce: in function test_01u: constrained Loop at depth 1 containing: %loop<header><exiting>,%in.bounds<latch><exiting>

‎llvm/test/Transforms/IRCE/low-becount.ll

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
; RUN: opt -irce-print-changed-loops -verify-loop-info -irce -S < %s 2>&1 | FileCheck %s
2+
;
3+
; TODO: new-pm version should be enabled after we decide on branch-probability handling for loop passes
4+
; TODO: opt -irce-print-changed-loops -verify-loop-info -passes='require<branch-prob>,loop(irce)' -S < %s 2>&1 | FileCheck %s
25

36
; CHECK-NOT: constrained Loop
47

‎llvm/test/Transforms/IRCE/multiple-access-no-preloop.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: opt -verify-loop-info -irce -S < %s | FileCheck %s
2+
; RUN: opt -verify-loop-info -passes='require<branch-prob>,loop(irce)' -S < %s | FileCheck %s
23

34
define void @multiple_access_no_preloop(
45
i32* %arr_a, i32* %a_len_ptr, i32* %arr_b, i32* %b_len_ptr, i32 %n) {

‎llvm/test/Transforms/IRCE/not-likely-taken.ll

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
; RUN: opt -verify-loop-info -irce-print-changed-loops -irce < %s 2>&1 | FileCheck %s
2+
;
3+
; TODO: new-pm version should be enabled after we decide on branch-probability handling for loop passes
4+
; TODO: opt -verify-loop-info -irce-print-changed-loops -passes='require<branch-prob>,loop(irce)' < %s 2>&1 | FileCheck %s
25

36
; CHECK-NOT: constrained Loop
47

@@ -37,4 +40,4 @@ define void @multiple_access_no_preloop(
3740
}
3841

3942
!0 = !{i32 0, i32 2147483647}
40-
!1 = !{!"branch_weights", i32 1, i32 1}
43+
!1 = !{!"branch_weights", i32 1, i32 1}

‎llvm/test/Transforms/IRCE/only-lower-check.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: opt -irce-print-range-checks -irce-print-changed-loops -verify-loop-info -irce < %s 2>&1 | FileCheck %s
2+
; RUN: opt -irce-print-range-checks -irce-print-changed-loops -verify-loop-info -passes='require<branch-prob>,loop(irce)' < %s 2>&1 | FileCheck %s
23

34
; CHECK: irce: loop has 1 inductive range checks:
45
; CHECK-NEXT: InductiveRangeCheck:

‎llvm/test/Transforms/IRCE/only-upper-check.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: opt -verify-loop-info -irce -irce-print-range-checks -irce-print-changed-loops %s -S 2>&1 | FileCheck %s
2+
; RUN: opt -verify-loop-info -passes='require<branch-prob>,loop(irce)' -irce-print-range-checks -irce-print-changed-loops %s -S 2>&1 | FileCheck %s
23

34
; CHECK: irce: loop has 1 inductive range checks:
45
; CHECK-NEXT:InductiveRangeCheck:

‎llvm/test/Transforms/IRCE/pre_post_loops.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: opt -verify-loop-info -irce-print-changed-loops -irce -S < %s 2>&1 | FileCheck %s
2+
; RUN: opt -verify-loop-info -irce-print-changed-loops -passes='require<branch-prob>,loop(irce)' -S < %s 2>&1 | FileCheck %s
23

34
; CHECK: irce: in function test_01: constrained Loop at depth 1 containing: %loop<header><exiting>,%in.bounds<latch><exiting>
45
; CHECK: irce: in function test_02: constrained Loop at depth 1 containing: %loop<header><exiting>,%in.bounds<latch><exiting>

‎llvm/test/Transforms/IRCE/range_intersect_miscompile.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: opt -verify-loop-info -irce-print-changed-loops -irce -S < %s 2>&1 | FileCheck %s
2+
; RUN: opt -verify-loop-info -irce-print-changed-loops -passes='require<branch-prob>,loop(irce)' -S < %s 2>&1 | FileCheck %s
23

34
; CHECK-LABEL: irce: in function test_01: constrained Loop at depth 1 containing:
45
; CHECK-LABEL: irce: in function test_02: constrained Loop at depth 1 containing:

‎llvm/test/Transforms/IRCE/ranges_of_different_types.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: opt -verify-loop-info -irce-print-changed-loops -irce -S < %s 2>&1 | FileCheck %s
2+
; RUN: opt -verify-loop-info -irce-print-changed-loops -passes='require<branch-prob>,loop(irce)' -S < %s 2>&1 | FileCheck %s
23

34
; Make sure we can eliminate range check with signed latch, unsigned IRC and
45
; positive offset. The safe iteration space is:

‎llvm/test/Transforms/IRCE/single-access-no-preloop.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: opt -verify-loop-info -irce -S < %s | FileCheck %s
2+
; RUN: opt -verify-loop-info -passes='require<branch-prob>,loop(irce)' -S < %s | FileCheck %s
23

34
define void @single_access_no_preloop_no_offset(i32 *%arr, i32 *%a_len_ptr, i32 %n) {
45
entry:

‎llvm/test/Transforms/IRCE/single-access-with-preloop.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: opt -verify-loop-info -irce -S < %s | FileCheck %s
2+
; RUN: opt -verify-loop-info -passes='require<branch-prob>,loop(irce)' -S < %s | FileCheck %s
23

34
define void @single_access_with_preloop(i32 *%arr, i32 *%a_len_ptr, i32 %n, i32 %offset) {
45
entry:

‎llvm/test/Transforms/IRCE/skip-profitability-checks.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: opt -irce-skip-profitability-checks -S -verify-loop-info -irce < %s | FileCheck %s
2+
; RUN: opt -irce-skip-profitability-checks -S -verify-loop-info -passes='require<branch-prob>,loop(irce)' < %s | FileCheck %s
23

34
define void @single_access_no_preloop_no_offset(i32 *%arr, i32 *%a_len_ptr, i32 %n) {
45
; CHECK-LABEL: @single_access_no_preloop_no_offset(

‎llvm/test/Transforms/IRCE/stride_more_than_1.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: opt -verify-loop-info -irce-print-changed-loops -irce -S < %s 2>&1 | FileCheck %s
2+
; RUN: opt -verify-loop-info -irce-print-changed-loops -passes='require<branch-prob>,loop(irce)' -S < %s 2>&1 | FileCheck %s
23

34
; CHECK: irce: in function test_01: constrained Loop at depth 1 containing: %loop<header><exiting>,%in.bounds<latch><exiting>
45
; CHECK: irce: in function test_02: constrained Loop at depth 1 containing: %loop<header><exiting>,%in.bounds<latch><exiting>

‎llvm/test/Transforms/IRCE/unhandled.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: opt -irce-print-changed-loops -verify-loop-info -irce -S < %s 2>&1 | FileCheck %s
2+
; RUN: opt -irce-print-changed-loops -verify-loop-info -passes='require<branch-prob>,loop(irce)' -S < %s 2>&1 | FileCheck %s
23

34
; CHECK-NOT: constrained Loop at depth
45

‎llvm/test/Transforms/IRCE/unsigned_comparisons_ugt.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: opt -verify-loop-info -irce-print-changed-loops -irce -S < %s 2>&1 | FileCheck %s
2+
; RUN: opt -verify-loop-info -irce-print-changed-loops -passes='require<branch-prob>,loop(irce)' -S < %s 2>&1 | FileCheck %s
23

34
; CHECK: irce: in function test_01: constrained Loop at depth 1 containing: %loop<header><exiting>,%in.bounds<latch><exiting>
45
; CHECK: irce: in function test_02: constrained Loop at depth 1 containing: %loop<header><exiting>,%in.bounds<latch><exiting>

‎llvm/test/Transforms/IRCE/unsigned_comparisons_ult.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: opt -verify-loop-info -irce-print-changed-loops -irce -S < %s 2>&1 | FileCheck %s
2+
; RUN: opt -verify-loop-info -irce-print-changed-loops -passes='require<branch-prob>,loop(irce)' -S < %s 2>&1 | FileCheck %s
23

34
; CHECK: irce: in function test_01: constrained Loop at depth 1 containing: %loop<header><exiting>,%in.bounds<latch><exiting>
45
; CHECK: irce: in function test_02: constrained Loop at depth 1 containing: %loop<header><exiting>,%in.bounds<latch><exiting>

‎llvm/test/Transforms/IRCE/with-parent-loops.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: opt -verify-loop-info -irce-print-changed-loops -irce < %s 2>&1 | FileCheck %s
2+
; RUN: opt -verify-loop-info -irce-print-changed-loops -passes='require<branch-prob>,loop(irce)' < %s 2>&1 | FileCheck %s
23

34
; This test checks if we update the LoopInfo correctly in the presence
45
; of parents, uncles and cousins.

0 commit comments

Comments
 (0)
Please sign in to comment.