[llvm] 98db277 - [LV] Do not check widening decision for instrs outside of loop.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 3 02:10:10 PDT 2020
Author: Florian Hahn
Date: 2020-08-03T10:09:24+01:00
New Revision: 98db27711d86d4085db4a4a8ff68f8baa1b094ef
URL: https://github.com/llvm/llvm-project/commit/98db27711d86d4085db4a4a8ff68f8baa1b094ef
DIFF: https://github.com/llvm/llvm-project/commit/98db27711d86d4085db4a4a8ff68f8baa1b094ef.diff
LOG: [LV] Do not check widening decision for instrs outside of loop.
No widening decisions will be computed for instructions outside the
loop. Do not try to get a widening decision. The load/store will be just
a scalar load, so treating at as normal should be fine I think.
Fixes PR46950.
Reviewed By: dmgreen
Differential Revision: https://reviews.llvm.org/D85087
Added:
llvm/test/Transforms/LoopVectorize/AArch64/pr46950-load-cast-context-crash.ll
Modified:
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 5fffcc8cf0f3..33bd31f6b983 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -6463,7 +6463,7 @@ unsigned LoopVectorizationCostModel::getInstructionCost(Instruction *I,
assert((isa<LoadInst>(I) || isa<StoreInst>(I)) &&
"Expected a load or a store!");
- if (VF == 1)
+ if (VF == 1 || !TheLoop->contains(I))
return TTI::CastContextHint::Normal;
switch (getWideningDecision(I, VF)) {
diff --git a/llvm/test/Transforms/LoopVectorize/AArch64/pr46950-load-cast-context-crash.ll b/llvm/test/Transforms/LoopVectorize/AArch64/pr46950-load-cast-context-crash.ll
new file mode 100644
index 000000000000..e357acca3fbf
--- /dev/null
+++ b/llvm/test/Transforms/LoopVectorize/AArch64/pr46950-load-cast-context-crash.ll
@@ -0,0 +1,25 @@
+; RUN: opt -loop-vectorize %s -mtriple=arm64-apple-iphoneos -S | FileCheck %s
+
+; CHECK-LABEL: define void @test(
+; CHECK: vector.body
+
+define void @test(i64* %dst, i32* %src) {
+entry:
+ %l = load i32, i32* %src
+ br label %loop.ph
+
+loop.ph:
+ br label %loop
+
+loop:
+ %iv = phi i64 [ 0, %loop.ph ], [ %iv.next, %loop ]
+ %l.cast = sext i32 %l to i64
+ %dst.idx = getelementptr i64, i64* %dst, i64 %iv
+ store i64 %l.cast, i64* %dst.idx
+ %iv.next = add nuw nsw i64 %iv, 1
+ %cmp9.us = icmp ult i64 %iv.next, 20
+ br i1 %cmp9.us, label %loop, label %exit
+
+exit:
+ ret void
+}
More information about the llvm-commits
mailing list