Skip to content

Commit 90b6e4b

Browse files
committed
[loop count assumptions] by default enable loop iteration assumption for AIE targets
1 parent 521184d commit 90b6e4b

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

clang/lib/Driver/ToolChains/AIE.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ void AIEToolChain::addClangTargetOptions(
184184

185185
// Extend the max limit of the search depth in BasicAA
186186
CC1Args.append({"-mllvm", "-basic-aa-max-lookup-search-depth=10"});
187+
188+
// Enable Loop Iteration Count Assumptions
189+
CC1Args.append({"-mllvm", "-enable-loop-iter-count-assumptions=true"});
187190
}
188191

189192
// Avoid using newer dwarf versions, as the simulator doesn't understand newer

clang/test/CodeGen/aie/peel-itercount.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
// and that the itercounts have been updated appropriately
1515

1616
// CHECK-LABEL: loop28_37
17-
// CHECK: for.body.preheader:
18-
// CHECK: for.body.peel.next:
17+
// CHECK: for.body.peel.next6:
18+
// CHECK: for.cond.cleanup:
19+
// CHECK: for.body:
1920
// CHECK: !llvm.loop !6
2021
// CHECK: !6 = distinct !{!6, !7, !8, !9}
2122
// CHECK: !7 = !{!"llvm.loop.peeled.count", i32 2}

llvm/lib/Passes/PassBuilderPipelines.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@
132132
#include "llvm/Transforms/Utils/CountVisits.h"
133133
#include "llvm/Transforms/Utils/InjectTLIMappings.h"
134134
#include "llvm/Transforms/Utils/LibCallsShrinkWrap.h"
135+
#include "llvm/Transforms/Utils/LoopIterCountAssumptions.h"
135136
#include "llvm/Transforms/Utils/Mem2Reg.h"
136137
#include "llvm/Transforms/Utils/MoveAutoInit.h"
137138
#include "llvm/Transforms/Utils/NameAnonGlobals.h"
@@ -306,6 +307,11 @@ static cl::opt<bool> UseLoopVersioningLICM(
306307
"enable-loop-versioning-licm", cl::init(false), cl::Hidden,
307308
cl::desc("Enable the experimental Loop Versioning LICM pass"));
308309

310+
static cl::opt<bool> EnableLoopIterCountToAssumptions(
311+
"enable-loop-iter-count-assumptions", cl::Hidden, cl::init(false),
312+
cl::desc(
313+
"Enable Conversion of Loop Iteration Count Metadata to Assumptions."));
314+
309315
namespace llvm {
310316
extern cl::opt<bool> EnableMemProfContextDisambiguation;
311317

@@ -463,6 +469,9 @@ PassBuilder::buildO1FunctionSimplificationPipeline(OptimizationLevel Level,
463469
LPM1.addPass(LICMPass(PTO.LicmMssaOptCap, PTO.LicmMssaNoAccForPromotionCap,
464470
/*AllowSpeculation=*/false));
465471

472+
if (EnableLoopIterCountToAssumptions)
473+
LPM1.addPass(LoopIterCountAssumptions());
474+
466475
LPM1.addPass(LoopRotatePass(/* Disable header duplication */ true,
467476
isLTOPreLink(Phase)));
468477
// TODO: Investigate promotion cap for O1.
@@ -644,6 +653,9 @@ PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level,
644653
LPM1.addPass(LICMPass(PTO.LicmMssaOptCap, PTO.LicmMssaNoAccForPromotionCap,
645654
/*AllowSpeculation=*/false));
646655

656+
if (EnableLoopIterCountToAssumptions)
657+
LPM1.addPass(LoopIterCountAssumptions());
658+
647659
// Disable header duplication in loop rotation at -Oz.
648660
LPM1.addPass(LoopRotatePass(EnableLoopHeaderDuplication ||
649661
Level != OptimizationLevel::Oz,

0 commit comments

Comments
 (0)