[PATCH] D85087: [LV] Do not check widening decision for instrs outside of loop.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 2 03:34:28 PDT 2020


fhahn created this revision.
fhahn added reviewers: dmgreen, Ayal.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
fhahn requested review of this revision.

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 PR46943.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85087

Files:
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/test/Transforms/LoopVectorize/AArch64/pr46943-load-cast-context-crash.ll


Index: llvm/test/Transforms/LoopVectorize/AArch64/pr46943-load-cast-context-crash.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/LoopVectorize/AArch64/pr46943-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
+}
Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -6463,7 +6463,7 @@
       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)) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85087.282437.patch
Type: text/x-patch
Size: 1376 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200802/0412b688/attachment-0001.bin>


More information about the llvm-commits mailing list