summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/LoopUnroll
diff options
context:
space:
mode:
authorAnna Thomas <anna@azul.com>2017-09-15 13:29:33 +0000
committerAnna Thomas <anna@azul.com>2017-09-15 13:29:33 +0000
commit512dde77ba7925f8911bc12de4f66e576ffe7c06 (patch)
tree69df7dd56f998025a8ed260486b486398a5e0dbd /llvm/test/Transforms/LoopUnroll
parent2a3209ed0a288bdd57e1addd87d9e8e49c4e7ece (diff)
downloadbcm5719-llvm-512dde77ba7925f8911bc12de4f66e576ffe7c06.tar.gz
bcm5719-llvm-512dde77ba7925f8911bc12de4f66e576ffe7c06.zip
[RuntimeUnrolling] Populate the VMap entry correctly when default generated through lookup
During runtime unrolling on loops with multiple exits, we update the exit blocks with the correct phi values from both original and remainder loop. In this process, we lookup the VMap for the mapped incoming phi values, but did not update the VMap if a default entry was generated in the VMap during the lookup. This default value is generated when constants or values outside the current loop are looked up. This patch fixes the assertion failure when null entries are present in the VMap because of this lookup. Added a testcase that showcases the problem. llvm-svn: 313358
Diffstat (limited to 'llvm/test/Transforms/LoopUnroll')
-rw-r--r--llvm/test/Transforms/LoopUnroll/runtime-loop-multiple-exits.ll44
1 files changed, 44 insertions, 0 deletions
diff --git a/llvm/test/Transforms/LoopUnroll/runtime-loop-multiple-exits.ll b/llvm/test/Transforms/LoopUnroll/runtime-loop-multiple-exits.ll
index 73672e14f78..ef983dffcd2 100644
--- a/llvm/test/Transforms/LoopUnroll/runtime-loop-multiple-exits.ll
+++ b/llvm/test/Transforms/LoopUnroll/runtime-loop-multiple-exits.ll
@@ -4,6 +4,8 @@
; RUN: opt < %s -loop-unroll -unroll-runtime=true -unroll-runtime-epilog=false -unroll-runtime-multi-exit=true -verify-dom-info -verify-loop-info -instcombine -S | FileCheck %s -check-prefix=PROLOG
; RUN: opt < %s -loop-unroll -unroll-runtime -unroll-runtime-epilog=false -unroll-count=2 -unroll-runtime-multi-exit=true -verify-dom-info -verify-loop-info -instcombine
+; REQUIRES: asserts
+
; the third and fifth RUNs generate an epilog/prolog remainder block for all the test
; cases below (it does not generate a loop).
@@ -478,3 +480,45 @@ latch: ; preds = %innerH
exit: ; preds = %latch
ret void
}
+
+declare i8 addrspace(1)* @foo(i32)
+; inner loop prolog unrolled
+; a value from outer loop is used in exit block of inner loop.
+; Don't create VMap entries for such values (%trip).
+define i8 addrspace(1)* @test9(i8* nocapture readonly %arg, i32 %n) {
+; PROLOG: test9(
+; PROLOG: header.prol:
+; PROLOG-NEXT: %phi.prol = phi i64 [ 0, %header.prol.preheader ], [ %iv.next.prol, %latch.prol ]
+; PROLOG: latch.prol:
+; PROLOG-NOT: trip
+; PROLOG: br i1 %prol.iter.cmp, label %header.prol.loopexit.unr-lcssa, label %header.prol
+bb:
+ br label %outerloopHdr
+
+outerloopHdr: ; preds = %outerLatch, %bb
+ %trip = add i32 %n, -1
+ %outercnd = icmp slt i32 0, %trip
+ br i1 %outercnd, label %preheader, label %outerLatch
+
+preheader: ; preds = %outerloopHdr
+ %tmp4 = zext i32 0 to i64
+ br label %header
+
+header: ; preds = %latch, %preheader
+ %phi = phi i64 [ %tmp4, %preheader ], [ %iv.next, %latch ]
+ %tmp7 = trunc i64 %phi to i32
+ br i1 true, label %latch, label %innerexit
+
+innerexit: ; preds = %header
+ %tmp9 = call i8 addrspace(1)* @foo(i32 %trip)
+ ret i8 addrspace(1)* %tmp9
+
+latch: ; preds = %header
+ %tmp11 = add nsw i32 %tmp7, 1
+ %innercnd = icmp slt i32 %tmp11, %trip
+ %iv.next = add nuw nsw i64 %phi, 1
+ br i1 %innercnd, label %header, label %outerLatch
+
+outerLatch: ; preds = %latch, %outerloopHdr
+ br label %outerloopHdr
+}
OpenPOWER on IntegriCloud