diff options
author | Anna Thomas <anna@azul.com> | 2017-07-10 15:29:38 +0000 |
---|---|---|
committer | Anna Thomas <anna@azul.com> | 2017-07-10 15:29:38 +0000 |
commit | 5be3d3e74b3530d1325ea9953b871e8eb28a9c96 (patch) | |
tree | ec1be4294172f4c96371205c579df91a1098fa79 | |
parent | 138dd5da1fa5af6ab2e4911e1d9b56847d028ad0 (diff) |
[LoopUnrollRuntime] Remove strict assert about VMap requirement
When unrolling under multiple exits which is under off-by-default option,
the assert that checks for VMap entry in loop exit values is too strong.
(assert if VMap entry did not exist, the value should be a
constant). However, values derived from
constants or from values outside loop, does not have a VMap entry too.
Removed the assert and added a testcase showcasing the property for
non-constant values.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307542 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/Utils/LoopUnrollRuntime.cpp | 7 | ||||
-rw-r--r-- | test/Transforms/LoopUnroll/runtime-loop-multiple-exits.ll | 43 |
2 files changed, 45 insertions, 5 deletions
diff --git a/lib/Transforms/Utils/LoopUnrollRuntime.cpp b/lib/Transforms/Utils/LoopUnrollRuntime.cpp index 8733a1388df..59408ffe7a7 100644 --- a/lib/Transforms/Utils/LoopUnrollRuntime.cpp +++ b/lib/Transforms/Utils/LoopUnrollRuntime.cpp @@ -710,11 +710,10 @@ bool llvm::UnrollRuntimeLoopRemainder(Loop *L, unsigned Count, // node. for (unsigned i =0; i < oldNumOperands; i++){ Value *newVal = VMap[Phi->getIncomingValue(i)]; - if (!newVal) { - assert(isa<Constant>(Phi->getIncomingValue(i)) && - "VMap should exist for all values except constants!"); + // newVal can be a constant or derived from values outside the loop, and + // hence need not have a VMap value. + if (!newVal) newVal = Phi->getIncomingValue(i); - } Phi->addIncoming(newVal, cast<BasicBlock>(VMap[Phi->getIncomingBlock(i)])); } diff --git a/test/Transforms/LoopUnroll/runtime-loop-multiple-exits.ll b/test/Transforms/LoopUnroll/runtime-loop-multiple-exits.ll index eaff2d6a743..18548c8af73 100644 --- a/test/Transforms/LoopUnroll/runtime-loop-multiple-exits.ll +++ b/test/Transforms/LoopUnroll/runtime-loop-multiple-exits.ll @@ -1,9 +1,10 @@ +; RUN: opt < %s -loop-unroll -unroll-runtime=true -unroll-runtime-epilog=true -unroll-runtime-multi-exit=true -verify-dom-info -verify-loop-info -S | FileCheck %s -check-prefix=EPILOG-NO-IC ; RUN: opt < %s -loop-unroll -unroll-runtime=true -unroll-runtime-epilog=true -unroll-runtime-multi-exit=true -verify-dom-info -verify-loop-info -instcombine -S | FileCheck %s -check-prefix=EPILOG ; RUN: opt < %s -loop-unroll -unroll-runtime -unroll-count=2 -unroll-runtime-epilog=true -unroll-runtime-multi-exit=true -verify-dom-info -verify-loop-info -instcombine ; 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 -; the second and fourth RUNs generate an epilog/prolog remainder block for all the test +; the third and fifth RUNs generate an epilog/prolog remainder block for all the test ; cases below (it does not generate a loop). ; test with three exiting and three exit blocks. @@ -393,3 +394,43 @@ exit_true: exit_false: ret i32 %addx } + +; test when value in exit block does not have VMap. +define i32 @test7(i32 %arg, i32 %arg1, i32 %arg2) { +; EPILOG-NO-IC: test7( +; EPILOG-NO-IC: loopexit1.loopexit: +; EPILOG-NO-IC-NEXT: %sext3.ph = phi i32 [ %shft, %header ], [ %shft, %latch ], [ %shft, %latch.1 ], [ %shft, %latch.2 ], [ %shft, %latch.3 ], [ %shft, %latch.4 ], [ %shft, %latch.5 ], [ %shft, %latch.6 ] +; EPILOG-NO-IC-NEXT: br label %loopexit1 +; EPILOG-NO-IC: loopexit1.loopexit1: +; EPILOG-NO-IC-NEXT: %sext3.ph2 = phi i32 [ %shft, %header.epil ] +; EPILOG-NO-IC-NEXT: br label %loopexit1 +; EPILOG-NO-IC: loopexit1: +; EPILOG-NO-IC-NEXT: %sext3 = phi i32 [ %sext3.ph, %loopexit1.loopexit ], [ %sext3.ph2, %loopexit1.loopexit1 ] +bb: + %tmp = icmp slt i32 undef, 2 + %sext = sext i32 undef to i64 + %shft = ashr exact i32 %arg, 16 + br i1 %tmp, label %loopexit2, label %preheader + +preheader: ; preds = %bb2 + br label %header + +header: ; preds = %latch, %preheader + %tmp6 = phi i64 [ 1, %preheader ], [ %add, %latch ] + br i1 false, label %loopexit1, label %latch + +latch: ; preds = %header + %add = add nuw nsw i64 %tmp6, 1 + %tmp9 = icmp slt i64 %add, %sext + br i1 %tmp9, label %header, label %latchexit + +latchexit: ; preds = %latch + unreachable + +loopexit2: ; preds = %bb2 + ret i32 %shft + +loopexit1: ; preds = %header + %sext3 = phi i32 [ %shft, %header ] + ret i32 %sext3 +} |