llvm.org GIT mirror llvm / 5be3d3e
[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 Anna Thomas 2 years ago
2 changed file(s) with 45 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
709709 // node.
710710 for (unsigned i =0; i < oldNumOperands; i++){
711711 Value *newVal = VMap[Phi->getIncomingValue(i)];
712 if (!newVal) {
713 assert(isa(Phi->getIncomingValue(i)) &&
714 "VMap should exist for all values except constants!");
712 // newVal can be a constant or derived from values outside the loop, and
713 // hence need not have a VMap value.
714 if (!newVal)
715715 newVal = Phi->getIncomingValue(i);
716 }
717716 Phi->addIncoming(newVal,
718717 cast(VMap[Phi->getIncomingBlock(i)]));
719718 }
0 ; 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
1 ; 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
12 ; 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
23 ; 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
34 ; 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
45
5 ; the second and fourth RUNs generate an epilog/prolog remainder block for all the test
6 ; the third and fifth RUNs generate an epilog/prolog remainder block for all the test
67 ; cases below (it does not generate a loop).
78
89 ; test with three exiting and three exit blocks.
392393 exit_false:
393394 ret i32 %addx
394395 }
396
397 ; test when value in exit block does not have VMap.
398 define i32 @test7(i32 %arg, i32 %arg1, i32 %arg2) {
399 ; EPILOG-NO-IC: test7(
400 ; EPILOG-NO-IC: loopexit1.loopexit:
401 ; 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 ]
402 ; EPILOG-NO-IC-NEXT: br label %loopexit1
403 ; EPILOG-NO-IC: loopexit1.loopexit1:
404 ; EPILOG-NO-IC-NEXT: %sext3.ph2 = phi i32 [ %shft, %header.epil ]
405 ; EPILOG-NO-IC-NEXT: br label %loopexit1
406 ; EPILOG-NO-IC: loopexit1:
407 ; EPILOG-NO-IC-NEXT: %sext3 = phi i32 [ %sext3.ph, %loopexit1.loopexit ], [ %sext3.ph2, %loopexit1.loopexit1 ]
408 bb:
409 %tmp = icmp slt i32 undef, 2
410 %sext = sext i32 undef to i64
411 %shft = ashr exact i32 %arg, 16
412 br i1 %tmp, label %loopexit2, label %preheader
413
414 preheader: ; preds = %bb2
415 br label %header
416
417 header: ; preds = %latch, %preheader
418 %tmp6 = phi i64 [ 1, %preheader ], [ %add, %latch ]
419 br i1 false, label %loopexit1, label %latch
420
421 latch: ; preds = %header
422 %add = add nuw nsw i64 %tmp6, 1
423 %tmp9 = icmp slt i64 %add, %sext
424 br i1 %tmp9, label %header, label %latchexit
425
426 latchexit: ; preds = %latch
427 unreachable
428
429 loopexit2: ; preds = %bb2
430 ret i32 %shft
431
432 loopexit1: ; preds = %header
433 %sext3 = phi i32 [ %shft, %header ]
434 ret i32 %sext3
435 }