Skip to content

Commit f29d060

Browse files
Revert "[LV] Mark checks as never succeeding for high cost cutoff."
This reverts commit 8a115b6. This broke premerge. https://lab.llvm.org/staging/#/builders/192/builds/13326 /home/gha/llvm-project/clang/test/Frontend/optimization-remark-options.c:10:11: remark: loop not vectorized: cannot prove it is safe to reorder floating-point operations; allow reordering by specifying '#pragma clang loop vectorize(enable)' before the loop or by providing the compiler option '-ffast-math'
1 parent 64ee4bf commit f29d060

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,12 +1827,8 @@ class GeneratedRTChecks {
18271827
// profile info.
18281828
CostTooHigh =
18291829
LAI.getNumRuntimePointerChecks() > VectorizeMemoryCheckThreshold;
1830-
if (CostTooHigh) {
1831-
// Mark runtime checks as never succeeding when they exceed the threshold.
1832-
MemRuntimeCheckCond = ConstantInt::getTrue(L->getHeader()->getContext());
1833-
SCEVCheckCond = ConstantInt::getTrue(L->getHeader()->getContext());
1830+
if (CostTooHigh)
18341831
return;
1835-
}
18361832

18371833
BasicBlock *LoopHeader = L->getHeader();
18381834
BasicBlock *Preheader = L->getLoopPreheader();

llvm/test/Transforms/LoopVectorize/runtime-check-threshold-with-force-metadata.ll

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,29 @@
22
; RUN: opt -p loop-vectorize -vectorize-memory-check-threshold=0 -S %s | FileCheck --check-prefix=LIMIT0 %s
33
; RUN: opt -p loop-vectorize -vectorize-memory-check-threshold=1 -S %s | FileCheck --check-prefix=LIMIT1 %s
44

5-
; Make sure we do not incorrectly vectorize with -vectorize-memory-check-threshold=0;
6-
; no runtime check is generated and the loop should not be vectorized.
5+
; FIXME: Currently this miscompiles with -vectorize-memory-check-threshold=0;
6+
; no runtime check is generated even though one is needed and !noalias
7+
; annotations are added.
78
define i16 @runtime_checks_needed(ptr %src, ptr %dst) {
89
; LIMIT0-LABEL: define i16 @runtime_checks_needed(
910
; LIMIT0-SAME: ptr [[SRC:%.*]], ptr [[DST:%.*]]) {
10-
; LIMIT0-NEXT: [[ENTRY:.*]]:
11-
; LIMIT0-NEXT: br label %[[LOOP:.*]]
12-
; LIMIT0: [[LOOP]]:
13-
; LIMIT0-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %[[ENTRY]] ], [ [[INDEX_NEXT:%.*]], %[[LOOP]] ]
14-
; LIMIT0-NEXT: [[L:%.*]] = load i16, ptr [[SRC]], align 1
11+
; LIMIT0-NEXT: [[ENTRY:.*:]]
12+
; LIMIT0-NEXT: br label %[[VECTOR_PH:.*]]
13+
; LIMIT0: [[VECTOR_PH]]:
14+
; LIMIT0-NEXT: [[TMP0:%.*]] = load i16, ptr [[SRC]], align 1, !alias.scope [[META0:![0-9]+]]
15+
; LIMIT0-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <2 x i16> poison, i16 [[TMP0]], i64 0
16+
; LIMIT0-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <2 x i16> [[BROADCAST_SPLATINSERT]], <2 x i16> poison, <2 x i32> zeroinitializer
17+
; LIMIT0-NEXT: br label %[[VECTOR_BODY:.*]]
18+
; LIMIT0: [[VECTOR_BODY]]:
19+
; LIMIT0-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]
1520
; LIMIT0-NEXT: [[TMP1:%.*]] = getelementptr inbounds i16, ptr [[DST]], i64 [[INDEX]]
16-
; LIMIT0-NEXT: store i16 [[L]], ptr [[TMP1]], align 1
17-
; LIMIT0-NEXT: [[INDEX_NEXT]] = add nuw nsw i64 [[INDEX]], 1
21+
; LIMIT0-NEXT: store <2 x i16> [[BROADCAST_SPLAT]], ptr [[TMP1]], align 1, !alias.scope [[META3:![0-9]+]], !noalias [[META0]]
22+
; LIMIT0-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 2
1823
; LIMIT0-NEXT: [[TMP2:%.*]] = icmp eq i64 [[INDEX_NEXT]], 1000
19-
; LIMIT0-NEXT: br i1 [[TMP2]], label %[[EXIT:.*]], label %[[LOOP]], !llvm.loop [[LOOP0:![0-9]+]]
24+
; LIMIT0-NEXT: br i1 [[TMP2]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP5:![0-9]+]]
25+
; LIMIT0: [[MIDDLE_BLOCK]]:
26+
; LIMIT0-NEXT: br label %[[EXIT:.*]]
2027
; LIMIT0: [[EXIT]]:
21-
; LIMIT0-NEXT: [[TMP0:%.*]] = phi i16 [ [[L]], %[[LOOP]] ]
2228
; LIMIT0-NEXT: ret i16 [[TMP0]]
2329
;
2430
; LIMIT1-LABEL: define i16 @runtime_checks_needed(
@@ -82,9 +88,14 @@ exit:
8288
!3 = !{!"llvm.loop.vectorize.enable", i1 true}
8389

8490
;.
85-
; LIMIT0: [[LOOP0]] = distinct !{[[LOOP0]], [[META1:![0-9]+]], [[META2:![0-9]+]]}
86-
; LIMIT0: [[META1]] = !{!"llvm.loop.vectorize.width", i32 2}
87-
; LIMIT0: [[META2]] = !{!"llvm.loop.vectorize.enable", i1 true}
91+
; LIMIT0: [[META0]] = !{[[META1:![0-9]+]]}
92+
; LIMIT0: [[META1]] = distinct !{[[META1]], [[META2:![0-9]+]]}
93+
; LIMIT0: [[META2]] = distinct !{[[META2]], !"LVerDomain"}
94+
; LIMIT0: [[META3]] = !{[[META4:![0-9]+]]}
95+
; LIMIT0: [[META4]] = distinct !{[[META4]], [[META2]]}
96+
; LIMIT0: [[LOOP5]] = distinct !{[[LOOP5]], [[META6:![0-9]+]], [[META7:![0-9]+]]}
97+
; LIMIT0: [[META6]] = !{!"llvm.loop.isvectorized", i32 1}
98+
; LIMIT0: [[META7]] = !{!"llvm.loop.unroll.runtime.disable"}
8899
;.
89100
; LIMIT1: [[META0]] = !{[[META1:![0-9]+]]}
90101
; LIMIT1: [[META1]] = distinct !{[[META1]], [[META2:![0-9]+]]}

0 commit comments

Comments
 (0)