Index: llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp =================================================================== --- llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp +++ llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp @@ -263,9 +263,6 @@ if (ICmpInst::isEquality(Pred) && !SE.isKnownPredicate(ICmpInst::getInversePredicate(Pred), NextIterVal, RightSCEV)) { - assert(!SE.isKnownPredicate(Pred, IterVal, RightSCEV) && - SE.isKnownPredicate(Pred, NextIterVal, RightSCEV) && - "Expected Pred to go from known to unknown."); if (!CanPeelOneMoreIteration()) continue; // Need to peel one more iteration, but can't. Give up. PeelOneMoreIteration(); // Great! Index: llvm/test/Transforms/LoopUnroll/wrong_assert_in_peeling.ll =================================================================== --- /dev/null +++ llvm/test/Transforms/LoopUnroll/wrong_assert_in_peeling.ll @@ -0,0 +1,49 @@ +; RUN: opt -S < %s -loop-unroll | FileCheck %s +; RUN: opt -S < %s -passes=unroll | FileCheck %s +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2" +target triple = "x86_64-unknown-linux-gnu" + +define i32 @test() { +; CHECK-LABEL: test +bb: + br label %bb1 + +bb1: ; preds = %bb13, %bb + %tmp = phi i32 [ -147, %bb ], [ %tmp14, %bb13 ] + br label %bb2 + +bb2: ; preds = %bb12, %bb1 + %tmp3 = phi i32 [ undef, %bb1 ], [ %tmp4, %bb12 ] + %tmp4 = add nsw i32 %tmp3, %tmp + br label %bb5 + +bb5: ; preds = %bb2 + %tmp6 = icmp eq i32 undef, 33 + br i1 %tmp6, label %bb7, label %bb15 + +bb7: ; preds = %bb5 + %tmp8 = sub nsw i32 %tmp3, undef + %tmp9 = icmp eq i32 %tmp8, 0 + br i1 %tmp9, label %bb10, label %bb10 + +bb10: ; preds = %bb7, %bb7 + %tmp11 = icmp eq i8 undef, 0 + br i1 %tmp11, label %bb12, label %bb17 + +bb12: ; preds = %bb10 + br i1 false, label %bb13, label %bb2 + +bb13: ; preds = %bb12 + %tmp14 = add nsw i32 %tmp, -1 + br label %bb1 + +bb15: ; preds = %bb5 + %tmp16 = call i32 (...) @llvm.experimental.deoptimize.i32(i32 17) [ "deopt"() ] + ret i32 %tmp16 + +bb17: ; preds = %bb10 + %tmp18 = call i32 (...) @llvm.experimental.deoptimize.i32(i32 6) [ "deopt"() ] + ret i32 %tmp18 +} + +declare i32 @llvm.experimental.deoptimize.i32(...)