Skip to content

Commit 0369dc9

Browse files
Sidharth Bavejaanhtuyenibm
authored andcommitted
[NFC] Separate Peeling Properties into its own struct
Summary: This patch makes the peeling properties of the loop accessible by other loop transformations. Author: sidbav (Sidharth Baveja) Reviewers: Whitney (Whitney Tsang), Meinersbur (Michael Kruse), skatkov (Serguei Katkov), ashlykov (Arkady Shlykov), bogner (Justin Bogner), hfinkel (Hal Finkel) Reviewed By: Meinersbur (Michael Kruse) Subscribers: fhahn (Florian Hahn), hiraditya (Aditya Kumar), llvm-commits, LLVM Tag: LLVM Differential Revision: https://reviews.llvm.org/D80580
1 parent 6965af4 commit 0369dc9

22 files changed

+180
-58
lines changed

llvm/include/llvm/Analysis/TargetTransformInfo.h

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -450,11 +450,6 @@ class TargetTransformInfo {
450450
/// transformation will select an unrolling factor based on the current cost
451451
/// threshold and other factors.
452452
unsigned Count;
453-
/// A forced peeling factor (the number of bodied of the original loop
454-
/// that should be peeled off before the loop body). When set to 0, the
455-
/// unrolling transformation will select a peeling factor based on profile
456-
/// information and other factors.
457-
unsigned PeelCount;
458453
/// Default unroll count for loops with run-time trip count.
459454
unsigned DefaultUnrollRuntimeCount;
460455
// Set the maximum unrolling factor. The unrolling factor may be selected
@@ -488,19 +483,10 @@ class TargetTransformInfo {
488483
bool Force;
489484
/// Allow using trip count upper bound to unroll loops.
490485
bool UpperBound;
491-
/// Allow peeling off loop iterations.
492-
bool AllowPeeling;
493-
/// Allow peeling off loop iterations for loop nests.
494-
bool AllowLoopNestsPeeling;
495486
/// Allow unrolling of all the iterations of the runtime loop remainder.
496487
bool UnrollRemainder;
497488
/// Allow unroll and jam. Used to enable unroll and jam for the target.
498489
bool UnrollAndJam;
499-
/// Allow peeling basing on profile. Uses to enable peeling off all
500-
/// iterations basing on provided profile.
501-
/// If the value is true the peeling cost model can decide to peel only
502-
/// some iterations and in this case it will set this to false.
503-
bool PeelProfiledIterations;
504490
/// Threshold for unroll and jam, for inner loop size. The 'Threshold'
505491
/// value above is used during unroll and jam for the outer loop size.
506492
/// This value is used in the same manner to limit the size of the inner
@@ -534,6 +520,28 @@ class TargetTransformInfo {
534520
/// intrinsic is supported.
535521
bool emitGetActiveLaneMask() const;
536522

523+
// Parameters that control the loop peeling transformation
524+
struct PeelingPreferences {
525+
/// A forced peeling factor (the number of bodied of the original loop
526+
/// that should be peeled off before the loop body). When set to 0, the
527+
/// a peeling factor based on profile information and other factors.
528+
unsigned PeelCount;
529+
/// Allow peeling off loop iterations.
530+
bool AllowPeeling;
531+
/// Allow peeling off loop iterations for loop nests.
532+
bool AllowLoopNestsPeeling;
533+
/// Allow peeling basing on profile. Uses to enable peeling off all
534+
/// iterations basing on provided profile.
535+
/// If the value is true the peeling cost model can decide to peel only
536+
/// some iterations and in this case it will set this to false.
537+
bool PeelProfiledIterations;
538+
};
539+
540+
/// Get target-customized preferences for the generic loop peeling
541+
/// transformation. The caller will initialize \p PP with the current
542+
/// target-independent defaults with information from \p L and \p SE.
543+
void getPeelingPreferences(Loop *L, ScalarEvolution &SE,
544+
PeelingPreferences &PP) const;
537545
/// @}
538546

539547
/// \name Scalar Target Information
@@ -1282,6 +1290,8 @@ class TargetTransformInfo::Concept {
12821290
virtual bool isLoweredToCall(const Function *F) = 0;
12831291
virtual void getUnrollingPreferences(Loop *L, ScalarEvolution &,
12841292
UnrollingPreferences &UP) = 0;
1293+
virtual void getPeelingPreferences(Loop *L, ScalarEvolution &SE,
1294+
PeelingPreferences &PP) = 0;
12851295
virtual bool isHardwareLoopProfitable(Loop *L, ScalarEvolution &SE,
12861296
AssumptionCache &AC,
12871297
TargetLibraryInfo *LibInfo,
@@ -1560,6 +1570,10 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
15601570
UnrollingPreferences &UP) override {
15611571
return Impl.getUnrollingPreferences(L, SE, UP);
15621572
}
1573+
void getPeelingPreferences(Loop *L, ScalarEvolution &SE,
1574+
PeelingPreferences &PP) override {
1575+
return Impl.getPeelingPreferences(L, SE, PP);
1576+
}
15631577
bool isHardwareLoopProfitable(Loop *L, ScalarEvolution &SE,
15641578
AssumptionCache &AC, TargetLibraryInfo *LibInfo,
15651579
HardwareLoopInfo &HWLoopInfo) override {

llvm/include/llvm/Analysis/TargetTransformInfoImpl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ class TargetTransformInfoImplBase {
150150
void getUnrollingPreferences(Loop *, ScalarEvolution &,
151151
TTI::UnrollingPreferences &) {}
152152

153+
void getPeelingPreferences(Loop *, ScalarEvolution &,
154+
TTI::PeelingPreferences &) {}
155+
153156
bool isLegalAddImmediate(int64_t Imm) { return false; }
154157

155158
bool isLegalICmpImmediate(int64_t Imm) { return false; }

llvm/include/llvm/CodeGen/BasicTTIImpl.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,14 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
451451
UP.BEInsns = 2;
452452
}
453453

454+
void getPeelingPreferences(Loop *L, ScalarEvolution &SE,
455+
TTI::PeelingPreferences &PP) {
456+
PP.PeelCount = 0;
457+
PP.AllowPeeling = true;
458+
PP.AllowLoopNestsPeeling = false;
459+
PP.PeelProfiledIterations = true;
460+
}
461+
454462
bool isHardwareLoopProfitable(Loop *L, ScalarEvolution &SE,
455463
AssumptionCache &AC,
456464
TargetLibraryInfo *LibInfo,

llvm/include/llvm/Transforms/Utils/UnrollLoop.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ bool UnrollRuntimeLoopRemainder(
9494

9595
void computePeelCount(Loop *L, unsigned LoopSize,
9696
TargetTransformInfo::UnrollingPreferences &UP,
97+
TargetTransformInfo::PeelingPreferences &PP,
9798
unsigned &TripCount, ScalarEvolution &SE);
9899

99100
bool canPeel(Loop *L);
@@ -119,6 +120,8 @@ bool computeUnrollCount(Loop *L, const TargetTransformInfo &TTI,
119120
unsigned MaxTripCount, bool MaxOrZero,
120121
unsigned &TripMultiple, unsigned LoopSize,
121122
TargetTransformInfo::UnrollingPreferences &UP,
123+
TargetTransformInfo::PeelingPreferences &PP,
124+
122125
bool &UseUpperBound);
123126

124127
void simplifyLoopAfterUnroll(Loop *L, bool SimplifyIVs, LoopInfo *LI,
@@ -133,9 +136,13 @@ TargetTransformInfo::UnrollingPreferences gatherUnrollingPreferences(
133136
BlockFrequencyInfo *BFI, ProfileSummaryInfo *PSI, int OptLevel,
134137
Optional<unsigned> UserThreshold, Optional<unsigned> UserCount,
135138
Optional<bool> UserAllowPartial, Optional<bool> UserRuntime,
136-
Optional<bool> UserUpperBound, Optional<bool> UserAllowPeeling,
137-
Optional<bool> UserAllowProfileBasedPeeling,
138-
Optional<unsigned> UserFullUnrollMaxCount);
139+
Optional<bool> UserUpperBound, Optional<unsigned> UserFullUnrollMaxCount);
140+
141+
TargetTransformInfo::PeelingPreferences
142+
gatherPeelingPreferences(Loop *L, ScalarEvolution &SE,
143+
const TargetTransformInfo &TTI,
144+
Optional<bool> UserAllowPeeling,
145+
Optional<bool> UserAllowProfileBasedPeeling);
139146

140147
unsigned ApproximateLoopSize(const Loop *L, unsigned &NumCalls,
141148
bool &NotDuplicatable, bool &Convergent,

llvm/lib/Analysis/TargetTransformInfo.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,11 @@ void TargetTransformInfo::getUnrollingPreferences(
327327
return TTIImpl->getUnrollingPreferences(L, SE, UP);
328328
}
329329

330+
void TargetTransformInfo::getPeelingPreferences(Loop *L, ScalarEvolution &SE,
331+
PeelingPreferences &PP) const {
332+
return TTIImpl->getPeelingPreferences(L, SE, PP);
333+
}
334+
330335
bool TargetTransformInfo::isLegalAddImmediate(int64_t Imm) const {
331336
return TTIImpl->isLegalAddImmediate(Imm);
332337
}

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,11 @@ void AArch64TTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
859859
getFalkorUnrollingPreferences(L, SE, UP);
860860
}
861861

862+
void AArch64TTIImpl::getPeelingPreferences(Loop *L, ScalarEvolution &SE,
863+
TTI::PeelingPreferences &PP) {
864+
BaseT::getPeelingPreferences(L, SE, PP);
865+
}
866+
862867
Value *AArch64TTIImpl::getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst,
863868
Type *ExpectedType) {
864869
switch (Inst->getIntrinsicID()) {

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ class AArch64TTIImpl : public BasicTTIImplBase<AArch64TTIImpl> {
153153
void getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
154154
TTI::UnrollingPreferences &UP);
155155

156+
void getPeelingPreferences(Loop *L, ScalarEvolution &SE,
157+
TTI::PeelingPreferences &PP);
158+
156159
Value *getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst,
157160
Type *ExpectedType);
158161

llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ void AMDGPUTTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
236236
}
237237
}
238238

239+
void AMDGPUTTIImpl::getPeelingPreferences(Loop *L, ScalarEvolution &SE,
240+
TTI::PeelingPreferences &PP) {
241+
BaseT::getPeelingPreferences(L, SE, PP);
242+
}
239243
unsigned GCNTTIImpl::getHardwareNumberOfRegisters(bool Vec) const {
240244
// The concept of vector registers doesn't really exist. Some packed vector
241245
// operations operate on the normal 32-bit registers.
@@ -990,6 +994,11 @@ void GCNTTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
990994
CommonTTI.getUnrollingPreferences(L, SE, UP);
991995
}
992996

997+
void GCNTTIImpl::getPeelingPreferences(Loop *L, ScalarEvolution &SE,
998+
TTI::PeelingPreferences &PP) {
999+
CommonTTI.getPeelingPreferences(L, SE, PP);
1000+
}
1001+
9931002
unsigned R600TTIImpl::getHardwareNumberOfRegisters(bool Vec) const {
9941003
return 4 * 128; // XXX - 4 channels. Should these count as vector instead?
9951004
}
@@ -1096,3 +1105,8 @@ void R600TTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
10961105
TTI::UnrollingPreferences &UP) {
10971106
CommonTTI.getUnrollingPreferences(L, SE, UP);
10981107
}
1108+
1109+
void R600TTIImpl::getPeelingPreferences(Loop *L, ScalarEvolution &SE,
1110+
TTI::PeelingPreferences &PP) {
1111+
CommonTTI.getPeelingPreferences(L, SE, PP);
1112+
}

llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ class AMDGPUTTIImpl final : public BasicTTIImplBase<AMDGPUTTIImpl> {
6161

6262
void getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
6363
TTI::UnrollingPreferences &UP);
64+
65+
void getPeelingPreferences(Loop *L, ScalarEvolution &SE,
66+
TTI::PeelingPreferences &PP);
6467
};
6568

6669
class GCNTTIImpl final : public BasicTTIImplBase<GCNTTIImpl> {
@@ -141,6 +144,9 @@ class GCNTTIImpl final : public BasicTTIImplBase<GCNTTIImpl> {
141144
void getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
142145
TTI::UnrollingPreferences &UP);
143146

147+
void getPeelingPreferences(Loop *L, ScalarEvolution &SE,
148+
TTI::PeelingPreferences &PP);
149+
144150
TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth) {
145151
assert(isPowerOf2_32(TyWidth) && "Ty width must be power of 2");
146152
return TTI::PSK_FastHardware;
@@ -258,6 +264,8 @@ class R600TTIImpl final : public BasicTTIImplBase<R600TTIImpl> {
258264

259265
void getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
260266
TTI::UnrollingPreferences &UP);
267+
void getPeelingPreferences(Loop *L, ScalarEvolution &SE,
268+
TTI::PeelingPreferences &PP);
261269
unsigned getHardwareNumberOfRegisters(bool Vec) const;
262270
unsigned getNumberOfRegisters(bool Vec) const;
263271
unsigned getRegisterBitWidth(bool Vector) const;

llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,6 +1582,11 @@ void ARMTTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
15821582
UP.Force = true;
15831583
}
15841584

1585+
void ARMTTIImpl::getPeelingPreferences(Loop *L, ScalarEvolution &SE,
1586+
TTI::PeelingPreferences &PP) {
1587+
BaseT::getPeelingPreferences(L, SE, PP);
1588+
}
1589+
15851590
bool ARMTTIImpl::useReductionIntrinsic(unsigned Opcode, Type *Ty,
15861591
TTI::ReductionFlags Flags) const {
15871592
return ST->hasMVEIntegerOps();

llvm/lib/Target/ARM/ARMTargetTransformInfo.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ class ARMTTIImpl : public BasicTTIImplBase<ARMTTIImpl> {
251251

252252
bool emitGetActiveLaneMask() const;
253253

254+
void getPeelingPreferences(Loop *L, ScalarEvolution &SE,
255+
TTI::PeelingPreferences &PP);
254256
bool shouldBuildLookupTablesForConstant(Constant *C) const {
255257
// In the ROPI and RWPI relocation models we can't have pointers to global
256258
// variables or functions in constant data, so don't convert switches to

llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,17 @@ HexagonTTIImpl::getPopcntSupport(unsigned IntTyWidthInBit) const {
7878
void HexagonTTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
7979
TTI::UnrollingPreferences &UP) {
8080
UP.Runtime = UP.Partial = true;
81+
}
82+
83+
void HexagonTTIImpl::getPeelingPreferences(Loop *L, ScalarEvolution &SE,
84+
TTI::PeelingPreferences &PP) {
85+
BaseT::getPeelingPreferences(L, SE, PP);
8186
// Only try to peel innermost loops with small runtime trip counts.
8287
if (L && L->empty() && canPeel(L) &&
8388
SE.getSmallConstantTripCount(L) == 0 &&
8489
SE.getSmallConstantMaxTripCount(L) > 0 &&
8590
SE.getSmallConstantMaxTripCount(L) <= 5) {
86-
UP.PeelCount = 2;
91+
PP.PeelCount = 2;
8792
}
8893
}
8994

llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ class HexagonTTIImpl : public BasicTTIImplBase<HexagonTTIImpl> {
6464
void getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
6565
TTI::UnrollingPreferences &UP);
6666

67+
void getPeelingPreferences(Loop *L, ScalarEvolution &SE,
68+
TTI::PeelingPreferences &PP);
69+
6770
/// Bias LSR towards creating post-increment opportunities.
6871
bool shouldFavorPostInc() const;
6972

llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,8 @@ void NVPTXTTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
155155
UP.Partial = UP.Runtime = true;
156156
UP.PartialThreshold = UP.Threshold / 4;
157157
}
158+
159+
void NVPTXTTIImpl::getPeelingPreferences(Loop *L, ScalarEvolution &SE,
160+
TTI::PeelingPreferences &PP) {
161+
BaseT::getPeelingPreferences(L, SE, PP);
162+
}

llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ class NVPTXTTIImpl : public BasicTTIImplBase<NVPTXTTIImpl> {
9595

9696
void getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
9797
TTI::UnrollingPreferences &UP);
98+
99+
void getPeelingPreferences(Loop *L, ScalarEvolution &SE,
100+
TTI::PeelingPreferences &PP);
101+
98102
bool hasVolatileVariant(Instruction *I, unsigned AddrSpace) {
99103
// Volatile loads/stores are only supported for shared and global address
100104
// spaces, or for generic AS that maps to them.

llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,10 @@ void PPCTTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
568568
BaseT::getUnrollingPreferences(L, SE, UP);
569569
}
570570

571+
void PPCTTIImpl::getPeelingPreferences(Loop *L, ScalarEvolution &SE,
572+
TTI::PeelingPreferences &PP) {
573+
BaseT::getPeelingPreferences(L, SE, PP);
574+
}
571575
// This function returns true to allow using coldcc calling convention.
572576
// Returning true results in coldcc being used for functions which are cold at
573577
// all call sites when the callers of the functions are not calling any other

llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ class PPCTTIImpl : public BasicTTIImplBase<PPCTTIImpl> {
6666
TargetLibraryInfo *LibInfo);
6767
void getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
6868
TTI::UnrollingPreferences &UP);
69+
void getPeelingPreferences(Loop *L, ScalarEvolution &SE,
70+
TTI::PeelingPreferences &PP);
6971
bool isLSRCostLess(TargetTransformInfo::LSRCost &C1,
7072
TargetTransformInfo::LSRCost &C2);
7173

llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,10 @@ void SystemZTTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
294294
UP.Force = true;
295295
}
296296

297+
void SystemZTTIImpl::getPeelingPreferences(Loop *L, ScalarEvolution &SE,
298+
TTI::PeelingPreferences &PP) {
299+
BaseT::getPeelingPreferences(L, SE, PP);
300+
}
297301

298302
bool SystemZTTIImpl::isLSRCostLess(TargetTransformInfo::LSRCost &C1,
299303
TargetTransformInfo::LSRCost &C2) {

llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ class SystemZTTIImpl : public BasicTTIImplBase<SystemZTTIImpl> {
5050
void getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
5151
TTI::UnrollingPreferences &UP);
5252

53+
void getPeelingPreferences(Loop *L, ScalarEvolution &SE,
54+
TTI::PeelingPreferences &PP);
55+
5356
bool isLSRCostLess(TargetTransformInfo::LSRCost &C1,
5457
TargetTransformInfo::LSRCost &C2);
5558
/// @}

llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ static bool computeUnrollAndJamCount(
158158
const SmallPtrSetImpl<const Value *> &EphValues,
159159
OptimizationRemarkEmitter *ORE, unsigned OuterTripCount,
160160
unsigned OuterTripMultiple, unsigned OuterLoopSize, unsigned InnerTripCount,
161-
unsigned InnerLoopSize, TargetTransformInfo::UnrollingPreferences &UP) {
161+
unsigned InnerLoopSize, TargetTransformInfo::UnrollingPreferences &UP,
162+
TargetTransformInfo::PeelingPreferences &PP) {
162163
// First up use computeUnrollCount from the loop unroller to get a count
163164
// for unrolling the outer loop, plus any loops requiring explicit
164165
// unrolling we leave to the unroller. This uses UP.Threshold /
@@ -168,7 +169,8 @@ static bool computeUnrollAndJamCount(
168169
bool UseUpperBound = false;
169170
bool ExplicitUnroll = computeUnrollCount(
170171
L, TTI, DT, LI, SE, EphValues, ORE, OuterTripCount, MaxTripCount,
171-
/*MaxOrZero*/ false, OuterTripMultiple, OuterLoopSize, UP, UseUpperBound);
172+
/*MaxOrZero*/ false, OuterTripMultiple, OuterLoopSize, UP, PP,
173+
UseUpperBound);
172174
if (ExplicitUnroll || UseUpperBound) {
173175
// If the user explicitly set the loop as unrolled, dont UnJ it. Leave it
174176
// for the unroller instead.
@@ -282,7 +284,9 @@ tryToUnrollAndJamLoop(Loop *L, DominatorTree &DT, LoopInfo *LI,
282284
OptimizationRemarkEmitter &ORE, int OptLevel) {
283285
TargetTransformInfo::UnrollingPreferences UP =
284286
gatherUnrollingPreferences(L, SE, TTI, nullptr, nullptr, OptLevel, None,
285-
None, None, None, None, None, None, None);
287+
None, None, None, None, None);
288+
TargetTransformInfo::PeelingPreferences PP =
289+
gatherPeelingPreferences(L, SE, TTI, None, None);
286290
if (AllowUnrollAndJam.getNumOccurrences() > 0)
287291
UP.UnrollAndJam = AllowUnrollAndJam;
288292
if (UnrollAndJamThreshold.getNumOccurrences() > 0)
@@ -367,7 +371,7 @@ tryToUnrollAndJamLoop(Loop *L, DominatorTree &DT, LoopInfo *LI,
367371
// Decide if, and by how much, to unroll
368372
bool IsCountSetExplicitly = computeUnrollAndJamCount(
369373
L, SubLoop, TTI, DT, LI, SE, EphValues, &ORE, OuterTripCount,
370-
OuterTripMultiple, OuterLoopSize, InnerTripCount, InnerLoopSize, UP);
374+
OuterTripMultiple, OuterLoopSize, InnerTripCount, InnerLoopSize, UP, PP);
371375
if (UP.Count <= 1)
372376
return LoopUnrollResult::Unmodified;
373377
// Unroll factor (Count) must be less or equal to TripCount.

0 commit comments

Comments
 (0)