Skip to content

Commit 1cee33e

Browse files
author
Whitney Tsang
committed
[LoopUnrollAndJam] Allow unroll and jam loops forced by user.
Summary: Allow unroll and jam loops forced by user. LoopUnrollAndJamPass is still disabled by default in the NPM pipeline, and can be controlled by -enable-npm-unroll-and-jam. Reviewed By: Meinersbur, dmgreen Differential Revision: https://reviews.llvm.org/D87786
1 parent 91ce8e1 commit 1cee33e

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,13 @@ tryToUnrollAndJamLoop(Loop *L, DominatorTree &DT, LoopInfo *LI,
288288
None, None, None, None, None);
289289
TargetTransformInfo::PeelingPreferences PP =
290290
gatherPeelingPreferences(L, SE, TTI, None, None);
291+
292+
TransformationMode EnableMode = hasUnrollAndJamTransformation(L);
293+
if (EnableMode & TM_Disable)
294+
return LoopUnrollResult::Unmodified;
295+
if (EnableMode & TM_ForcedByUser)
296+
UP.UnrollAndJam = true;
297+
291298
if (AllowUnrollAndJam.getNumOccurrences() > 0)
292299
UP.UnrollAndJam = AllowUnrollAndJam;
293300
if (UnrollAndJamThreshold.getNumOccurrences() > 0)
@@ -300,10 +307,6 @@ tryToUnrollAndJamLoop(Loop *L, DominatorTree &DT, LoopInfo *LI,
300307
<< L->getHeader()->getParent()->getName() << "] Loop %"
301308
<< L->getHeader()->getName() << "\n");
302309

303-
TransformationMode EnableMode = hasUnrollAndJamTransformation(L);
304-
if (EnableMode & TM_Disable)
305-
return LoopUnrollResult::Unmodified;
306-
307310
// A loop with any unroll pragma (enabling/disabling/count/etc) is left for
308311
// the unroller, so long as it does not explicitly have unroll_and_jam
309312
// metadata. This means #pragma nounroll will disable unroll and jam as well

llvm/test/Transforms/LoopUnrollAndJam/pragma-explicit.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
; RUN: opt -loop-unroll-and-jam -allow-unroll-and-jam -unroll-runtime -unroll-partial-threshold=60 < %s -S | FileCheck %s
2-
; RUN: opt -aa-pipeline=tbaa,basic-aa -passes='loop-unroll-and-jam' -allow-unroll-and-jam -unroll-runtime -unroll-partial-threshold=60 < %s -S | FileCheck %s
1+
; RUN: opt -loop-unroll-and-jam -unroll-runtime -unroll-partial-threshold=60 < %s -S | FileCheck %s
2+
; RUN: opt -aa-pipeline=tbaa,basic-aa -passes='loop-unroll-and-jam' -unroll-runtime -unroll-partial-threshold=60 < %s -S | FileCheck %s
33

44
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
55
target triple = "x86_64-unknown-linux-gnu"

0 commit comments

Comments
 (0)