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 10, 2024
1 parent a7e2287 commit f9835c9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 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=1"});
}

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

// CHECK-LABEL: loop28_37
// CHECK: entry
// CHECK: for.body.preheader:
// CHECK: for.body.peel.next:
// CHECK: for.cond.cleanup:
// CHECK: for.cond.cleanup:
// CHECK: for.body:
// CHECK: !llvm.loop !6
// CHECK: !6 = distinct !{!6, !7, !8, !9}
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
1 change: 1 addition & 0 deletions llvm/lib/Target/AIE/AIEBaseTargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "llvm/Transforms/IPO/GlobalDCE.h"
#include "llvm/Transforms/IPO/Internalize.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Utils/LoopIterCountAssumptions.h"

using namespace llvm;

Expand Down

0 comments on commit f9835c9

Please sign in to comment.