Skip to content

Commit

Permalink
[loop count assumptions] by default enable loop iteration assumption …
Browse files Browse the repository at this point in the history
…for AIE targets
  • Loading branch information
F-Stuckmann committed Dec 11, 2024
1 parent 231a5da commit 0c6fa61
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
3 changes: 3 additions & 0 deletions clang/lib/Driver/ToolChains/AIE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ void AIEToolChain::addClangTargetOptions(

// Extend the max limit of the search depth in BasicAA
CC1Args.append({"-mllvm", "-basic-aa-max-lookup-search-depth=10"});

// Enable Loop Iteration Count Assumptions
CC1Args.append({"-mllvm", "-enable-loop-iter-count-assumptions=true"});
}

// Avoid using newer dwarf versions, as the simulator doesn't understand newer
Expand Down
5 changes: 3 additions & 2 deletions clang/test/CodeGen/aie/peel-itercount.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
// and that the itercounts have been updated appropriately

// CHECK-LABEL: loop28_37
// CHECK: for.body.preheader:
// CHECK: for.body.peel.next:
// CHECK: for.body.peel.next6:
// CHECK: for.cond.cleanup:
// CHECK: for.body:
// CHECK: !llvm.loop !6
// CHECK: !6 = distinct !{!6, !7, !8, !9}
// CHECK: !7 = !{!"llvm.loop.peeled.count", i32 2}
Expand Down
12 changes: 12 additions & 0 deletions llvm/lib/Passes/PassBuilderPipelines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
#include "llvm/Transforms/Utils/CountVisits.h"
#include "llvm/Transforms/Utils/InjectTLIMappings.h"
#include "llvm/Transforms/Utils/LibCallsShrinkWrap.h"
#include "llvm/Transforms/Utils/LoopIterCountAssumptions.h"
#include "llvm/Transforms/Utils/Mem2Reg.h"
#include "llvm/Transforms/Utils/MoveAutoInit.h"
#include "llvm/Transforms/Utils/NameAnonGlobals.h"
Expand Down Expand Up @@ -306,6 +307,11 @@ static cl::opt<bool> UseLoopVersioningLICM(
"enable-loop-versioning-licm", cl::init(false), cl::Hidden,
cl::desc("Enable the experimental Loop Versioning LICM pass"));

static cl::opt<bool> EnableLoopIterCountToAssumptions(
"enable-loop-iter-count-assumptions", cl::Hidden, cl::init(false),
cl::desc(
"Enable Conversion of Loop Iteration Count Metadata to Assumptions."));

namespace llvm {
extern cl::opt<bool> EnableMemProfContextDisambiguation;

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

if (EnableLoopIterCountToAssumptions)
LPM1.addPass(LoopIterCountAssumptions());

LPM1.addPass(LoopRotatePass(/* Disable header duplication */ true,
isLTOPreLink(Phase)));
// TODO: Investigate promotion cap for O1.
Expand Down Expand Up @@ -644,6 +653,9 @@ PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level,
LPM1.addPass(LICMPass(PTO.LicmMssaOptCap, PTO.LicmMssaNoAccForPromotionCap,
/*AllowSpeculation=*/false));

if (EnableLoopIterCountToAssumptions)
LPM1.addPass(LoopIterCountAssumptions());

// Disable header duplication in loop rotation at -Oz.
LPM1.addPass(LoopRotatePass(EnableLoopHeaderDuplication ||
Level != OptimizationLevel::Oz,
Expand Down

0 comments on commit 0c6fa61

Please sign in to comment.