Skip to content

Commit 901cd3b

Browse files
author
Sjoerd Meijer
committed
[LV] PreferPredicateOverEpilog respecting option
Follow-up of cb47b87: don't query TTI->preferPredicateOverEpilogue when option -prefer-predicate-over-epilog is set to false, i.e. when we prefer not to predicate the loop. Differential Revision: https://reviews.llvm.org/D70382
1 parent 8cf8ec4 commit 901cd3b

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7429,14 +7429,18 @@ getScalarEpilogueLowering(Function *F, Loop *L, LoopVectorizeHints &Hints,
74297429
ScalarEvolution *SE, DominatorTree *DT,
74307430
const LoopAccessInfo *LAI) {
74317431
ScalarEpilogueLowering SEL = CM_ScalarEpilogueAllowed;
7432+
bool PredicateOptDisabled = PreferPredicateOverEpilog.getNumOccurrences() &&
7433+
!PreferPredicateOverEpilog;
7434+
74327435
if (Hints.getForce() != LoopVectorizeHints::FK_Enabled &&
74337436
(F->hasOptSize() ||
74347437
llvm::shouldOptimizeForSize(L->getHeader(), PSI, BFI)))
74357438
SEL = CM_ScalarEpilogueNotAllowedOptSize;
74367439
else if (PreferPredicateOverEpilog ||
74377440
Hints.getPredicate() == LoopVectorizeHints::FK_Enabled ||
74387441
(TTI->preferPredicateOverEpilogue(L, LI, *SE, *AC, TLI, DT, LAI) &&
7439-
Hints.getPredicate() != LoopVectorizeHints::FK_Disabled))
7442+
Hints.getPredicate() != LoopVectorizeHints::FK_Disabled &&
7443+
!PredicateOptDisabled))
74407444
SEL = CM_ScalarEpilogueNotNeededUsePredicate;
74417445

74427446
return SEL;

llvm/test/Transforms/LoopVectorize/ARM/prefer-tail-loop-folding.ll

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@
3030
; RUN: -enable-arm-maskedldst=true -S < %s | \
3131
; RUN: FileCheck %s -check-prefixes=CHECK,PREFER-FOLDING
3232

33+
; RUN: opt -mtriple=thumbv8.1m.main-arm-eabihf -mattr=+mve.fp \
34+
; RUN: -prefer-predicate-over-epilog=false \
35+
; RUN: -disable-mve-tail-predication=false -loop-vectorize \
36+
; RUN: -enable-arm-maskedldst=true -S < %s | \
37+
; RUN: FileCheck %s -check-prefixes=CHECK,NO-FOLDING
38+
39+
; RUN: opt -mtriple=thumbv8.1m.main-arm-eabihf -mattr=+mve.fp \
40+
; RUN: -prefer-predicate-over-epilog=true \
41+
; RUN: -disable-mve-tail-predication=false -loop-vectorize \
42+
; RUN: -enable-arm-maskedldst=true -S < %s | \
43+
; RUN: FileCheck %s -check-prefixes=CHECK,FOLDING-OPT
44+
3345
define void @prefer_folding(i32* noalias nocapture %A, i32* noalias nocapture readonly %B, i32* noalias nocapture readonly %C) #0 {
3446
; CHECK-LABEL: prefer_folding(
3547
; PREFER-FOLDING: vector.body:
@@ -186,6 +198,12 @@ define void @narrowing_load_not_allowed(i8* noalias nocapture %A, i8* noalias no
186198
; PREFER-FOLDING-NOT: llvm.masked.load
187199
; PREFER-FOLDING-NOT: llvm.masked.store
188200
; PREFER-FOLDING: br i1 %{{.*}}, label %{{.*}}, label %vector.body
201+
202+
; FOLDING-OPT: vector.body:
203+
; FOLDING-OPT call <8 x i16> @llvm.masked.load.v8i16.p0v8i16
204+
; FOLDING-OPT call <8 x i8> @llvm.masked.load.v8i8.p0v8i8
205+
; FOLDING-OPT call void @llvm.masked.store.v8i8.p0v8i8
206+
; FOLDING-OPT: br i1 %{{.*}}, label %{{.*}}, label %vector.body
189207
entry:
190208
br label %for.body
191209

0 commit comments

Comments
 (0)