Skip to content

Commit f245610

Browse files
committed
Remove LV::useSafeEltsMask
1 parent 8a077e9 commit f245610

File tree

3 files changed

+16
-20
lines changed

3 files changed

+16
-20
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,7 +1344,10 @@ class LoopVectorizationCostModel {
13441344
: ChosenTailFoldingStyle->second;
13451345
}
13461346

1347-
RTCheckStyle getRTCheckStyle(TailFoldingStyle TFStyle) const {
1347+
RTCheckStyle getRTCheckStyle(TailFoldingStyle TFStyle, const TargetTransformInfo &TTI) const {
1348+
if (!TTI.useSafeEltsMask())
1349+
return RTCheckStyle::ScalarDifference;
1350+
13481351
switch (TFStyle) {
13491352
case TailFoldingStyle::Data:
13501353
case TailFoldingStyle::DataAndControlFlow:
@@ -1355,8 +1358,8 @@ class LoopVectorizationCostModel {
13551358
}
13561359
}
13571360

1358-
RTCheckStyle getRTCheckStyle() const {
1359-
return getRTCheckStyle(getTailFoldingStyle());
1361+
RTCheckStyle getRTCheckStyle(const TargetTransformInfo &TTI) const {
1362+
return getRTCheckStyle(getTailFoldingStyle(), TTI);
13601363
}
13611364

13621365
/// Selects and saves TailFoldingStyle for 2 options - if IV update may
@@ -2079,12 +2082,6 @@ static bool useActiveLaneMaskForControlFlow(TailFoldingStyle Style) {
20792082
Style == TailFoldingStyle::DataAndControlFlowWithoutRuntimeCheck;
20802083
}
20812084

2082-
static bool useSafeEltsMask(TailFoldingStyle TFStyle, RTCheckStyle Style,
2083-
const TargetTransformInfo &TTI) {
2084-
return useActiveLaneMask(TFStyle) && Style == RTCheckStyle::UseSafeEltsMask &&
2085-
TTI.useSafeEltsMask();
2086-
}
2087-
20882085
// Return true if \p OuterLp is an outer loop annotated with hints for explicit
20892086
// vectorization. The loop needs to be annotated with #pragma omp simd
20902087
// simdlen(#) or #pragma clang vectorize(enable) vectorize_width(#). If the
@@ -8940,7 +8937,7 @@ VPlanPtr LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(
89408937
std::optional<ArrayRef<PointerDiffInfo>> RTChecks =
89418938
CM.Legal->getRuntimePointerChecking()->getDiffChecks();
89428939
if (RTChecks.has_value() &&
8943-
useSafeEltsMask(Style, CM.getRTCheckStyle(Style), TTI))
8940+
CM.getRTCheckStyle(Style, TTI) == RTCheckStyle::UseSafeEltsMask)
89448941
DiffChecks = *RTChecks;
89458942

89468943
VPlanTransforms::addActiveLaneMask(*Plan, ForControlFlow,
@@ -10150,7 +10147,7 @@ bool LoopVectorizePass::processLoop(Loop *L) {
1015010147
if (VF.Width.isVector() || SelectedIC > 1) {
1015110148
TailFoldingStyle TFStyle = CM.getTailFoldingStyle();
1015210149
bool UseSafeEltsMask =
10153-
useSafeEltsMask(TFStyle, CM.getRTCheckStyle(TFStyle), *TTI);
10150+
CM.getRTCheckStyle(TFStyle, *TTI) == RTCheckStyle::UseSafeEltsMask;
1015410151
if (UseSafeEltsMask)
1015510152
LoopsAliasMasked++;
1015610153
Checks.create(L, *LVL.getLAI(), PSE.getPredicate(), VF.Width, SelectedIC,

llvm/test/Transforms/LoopVectorize/AArch64/induction-costs-sve.ll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,19 @@ define void @iv_casts(ptr %dst, ptr %src, i32 %x, i64 %N) #0 {
8888
; PRED-LABEL: define void @iv_casts(
8989
; PRED-SAME: ptr [[DST:%.*]], ptr [[SRC:%.*]], i32 [[X:%.*]], i64 [[N:%.*]]) #[[ATTR0:[0-9]+]] {
9090
; PRED-NEXT: [[ENTRY:.*]]:
91-
; PRED-NEXT: [[SRC3:%.*]] = ptrtoint ptr [[SRC]] to i64
92-
; PRED-NEXT: [[DST2:%.*]] = ptrtoint ptr [[DST]] to i64
91+
; PRED-NEXT: [[SRC2:%.*]] = ptrtoint ptr [[SRC]] to i64
92+
; PRED-NEXT: [[DST1:%.*]] = ptrtoint ptr [[DST]] to i64
9393
; PRED-NEXT: [[TMP0:%.*]] = add i64 [[N]], 1
9494
; PRED-NEXT: br i1 false, label %[[SCALAR_PH:.*]], label %[[VECTOR_MEMCHECK:.*]]
9595
; PRED: [[VECTOR_MEMCHECK]]:
9696
; PRED-NEXT: [[TMP1:%.*]] = call i64 @llvm.vscale.i64()
9797
; PRED-NEXT: [[TMP2:%.*]] = mul nuw i64 [[TMP1]], 16
98-
; PRED-NEXT: [[TMP3:%.*]] = sub i64 [[DST2]], [[SRC3]]
98+
; PRED-NEXT: [[TMP3:%.*]] = sub i64 [[DST1]], [[SRC2]]
9999
; PRED-NEXT: [[DIFF_CHECK:%.*]] = icmp ult i64 [[TMP3]], [[TMP2]]
100100
; PRED-NEXT: br i1 [[DIFF_CHECK]], label %[[SCALAR_PH]], label %[[VECTOR_PH:.*]]
101101
; PRED: [[VECTOR_PH]]:
102-
; PRED-NEXT: [[TMP9:%.*]] = call i64 @llvm.vscale.i64()
103-
; PRED-NEXT: [[TMP10:%.*]] = mul nuw i64 [[TMP9]], 16
102+
; PRED-NEXT: [[TMP4:%.*]] = call i64 @llvm.vscale.i64()
103+
; PRED-NEXT: [[TMP5:%.*]] = mul nuw i64 [[TMP4]], 16
104104
; PRED-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <vscale x 16 x i32> poison, i32 [[X]], i64 0
105105
; PRED-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <vscale x 16 x i32> [[BROADCAST_SPLATINSERT]], <vscale x 16 x i32> poison, <vscale x 16 x i32> zeroinitializer
106106
; PRED-NEXT: [[TMP11:%.*]] = call i64 @llvm.vscale.i64()
@@ -124,7 +124,7 @@ define void @iv_casts(ptr %dst, ptr %src, i32 %x, i64 %N) #0 {
124124
; PRED-NEXT: [[TMP23:%.*]] = trunc <vscale x 16 x i16> [[TMP21]] to <vscale x 16 x i8>
125125
; PRED-NEXT: [[TMP26:%.*]] = getelementptr i8, ptr [[DST]], i64 [[INDEX]]
126126
; PRED-NEXT: call void @llvm.masked.store.nxv16i8.p0(<vscale x 16 x i8> [[TMP23]], ptr [[TMP26]], i32 1, <vscale x 16 x i1> [[ACTIVE_LANE_MASK]])
127-
; PRED-NEXT: [[INDEX_NEXT]] = add i64 [[INDEX]], [[TMP10]]
127+
; PRED-NEXT: [[INDEX_NEXT]] = add i64 [[INDEX]], [[TMP5]]
128128
; PRED-NEXT: [[ACTIVE_LANE_MASK_NEXT]] = call <vscale x 16 x i1> @llvm.get.active.lane.mask.nxv16i1.i64(i64 [[INDEX]], i64 [[TMP15]])
129129
; PRED-NEXT: [[TMP25:%.*]] = extractelement <vscale x 16 x i1> [[ACTIVE_LANE_MASK_NEXT]], i32 0
130130
; PRED-NEXT: [[TMP27:%.*]] = xor i1 [[TMP25]], true

llvm/test/Transforms/LoopVectorize/runtime-checks-difference.ll

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,21 +339,20 @@ exit:
339339
; of the outer loop as start value. It is sufficient to subtract the start
340340
; values (%dst, %src) of the outer AddRecs.
341341
define void @nested_loop_start_of_inner_ptr_addrec_is_same_outer_addrec(ptr nocapture noundef %dst, ptr nocapture noundef readonly %src, i64 noundef %m, i64 noundef %n) {
342-
;
343342
; CHECK-LABEL: define void @nested_loop_start_of_inner_ptr_addrec_is_same_outer_addrec(
344343
; CHECK-SAME: ptr noundef captures(none) [[DST:%.*]], ptr noundef readonly captures(none) [[SRC:%.*]], i64 noundef [[M:%.*]], i64 noundef [[N:%.*]]) {
345344
; CHECK-NEXT: [[ENTRY:.*]]:
346345
; CHECK-NEXT: [[SRC2:%.*]] = ptrtoint ptr [[SRC]] to i64
347346
; CHECK-NEXT: [[DST1:%.*]] = ptrtoint ptr [[DST]] to i64
348-
; CHECK-NEXT: [[TMP0:%.*]] = sub i64 [[DST1]], [[SRC2]]
347+
; CHECK-NEXT: [[SUB:%.*]] = sub i64 [[DST1]], [[SRC2]]
349348
; CHECK-NEXT: br label %[[OUTER_LOOP:.*]]
350349
; CHECK: [[OUTER_LOOP]]:
351350
; CHECK-NEXT: [[OUTER_IV:%.*]] = phi i64 [ 0, %[[ENTRY]] ], [ [[OUTER_IV_NEXT:%.*]], [[INNER_EXIT:%.*]] ]
352351
; CHECK-NEXT: [[MUL:%.*]] = mul nsw i64 [[OUTER_IV]], [[N]]
353352
; CHECK-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ult i64 [[N]], 4
354353
; CHECK-NEXT: br i1 [[MIN_ITERS_CHECK]], [[SCALAR_PH:label %.*]], label %[[VECTOR_MEMCHECK:.*]]
355354
; CHECK: [[VECTOR_MEMCHECK]]:
356-
; CHECK-NEXT: [[DIFF_CHECK:%.*]] = icmp ult i64 [[TMP0]], 16
355+
; CHECK-NEXT: [[DIFF_CHECK:%.*]] = icmp ult i64 [[SUB]], 16
357356
; CHECK-NEXT: br i1 [[DIFF_CHECK]], [[SCALAR_PH]], [[VECTOR_PH:label %.*]]
358357
;
359358
entry:

0 commit comments

Comments
 (0)