[LV] PreferPredicateOverEpilog respecting predicate loop hint
The vectoriser queries TTI->preferPredicateOverEpilogue to determine if tail-folding is preferred for a loop, but it was not respecting loop hint 'predicate' that can disable this, which has now been added. This showed that we were incorrectly initialising loop hint 'vectorize.predicate.enable' with 0 (i.e. FK_Disabled) but this should have been FK_Undefined, which has been fixed. Differential Revision: https://reviews.llvm.org/D70125
This commit is contained in:
@@ -72,7 +72,7 @@ LoopVectorizeHints::LoopVectorizeHints(const Loop *L,
|
||||
Interleave("interleave.count", InterleaveOnlyWhenForced, HK_UNROLL),
|
||||
Force("vectorize.enable", FK_Undefined, HK_FORCE),
|
||||
IsVectorized("isvectorized", 0, HK_ISVECTORIZED),
|
||||
Predicate("vectorize.predicate.enable", 0, HK_PREDICATE), TheLoop(L),
|
||||
Predicate("vectorize.predicate.enable", FK_Undefined, HK_PREDICATE), TheLoop(L),
|
||||
ORE(ORE) {
|
||||
// Populate values with existing loop metadata.
|
||||
getHintsFromMetadata();
|
||||
|
||||
@@ -7433,8 +7433,10 @@ getScalarEpilogueLowering(Function *F, Loop *L, LoopVectorizeHints &Hints,
|
||||
(F->hasOptSize() ||
|
||||
llvm::shouldOptimizeForSize(L->getHeader(), PSI, BFI)))
|
||||
SEL = CM_ScalarEpilogueNotAllowedOptSize;
|
||||
else if (PreferPredicateOverEpilog || Hints.getPredicate() ||
|
||||
TTI->preferPredicateOverEpilogue(L, LI, *SE, *AC, TLI, DT, LAI))
|
||||
else if (PreferPredicateOverEpilog ||
|
||||
Hints.getPredicate() == LoopVectorizeHints::FK_Enabled ||
|
||||
(TTI->preferPredicateOverEpilogue(L, LI, *SE, *AC, TLI, DT, LAI) &&
|
||||
Hints.getPredicate() != LoopVectorizeHints::FK_Disabled))
|
||||
SEL = CM_ScalarEpilogueNotNeededUsePredicate;
|
||||
|
||||
return SEL;
|
||||
|
||||
@@ -323,15 +323,12 @@ for.end:
|
||||
}
|
||||
|
||||
define void @pragma_vect_predicate_disable(i32* noalias nocapture %A, i32* noalias nocapture readonly %B, i32* noalias nocapture readonly %C) #0 {
|
||||
; CHECK-LABEL: pragma_vect_predicate_disable(
|
||||
;
|
||||
; FIXME:
|
||||
; respect loop hint predicate.enable = false, and don't tail-fold here:
|
||||
;
|
||||
; PREFER-FOLDING: call <4 x i32> @llvm.masked.load.v4i32.p0v4i32
|
||||
; PREFER-FOLDING: call <4 x i32> @llvm.masked.load.v4i32.p0v4i32
|
||||
; PREFER-FOLDING: call void @llvm.masked.store.v4i32.p0v4i32
|
||||
; PREFER-FOLDING: br i1 %{{.*}}, label %{{.*}}, label %vector.body
|
||||
; CHECK-LABEL: pragma_vect_predicate_disable(
|
||||
; PREFER-FOLDING: vector.body:
|
||||
; PREFER-FOLDING-NOT: call <4 x i32> @llvm.masked.load.v4i32.p0v4i32
|
||||
; PREFER-FOLDING-NOT: call <4 x i32> @llvm.masked.load.v4i32.p0v4i32
|
||||
; PREFER-FOLDING-NOT: call void @llvm.masked.store.v4i32.p0v4i32
|
||||
; PREFER-FOLDING: br i1 %{{.*}}, label %{{.*}}, label %vector.body
|
||||
entry:
|
||||
br label %for.body
|
||||
|
||||
|
||||
Reference in New Issue
Block a user