35 lines · plain
1; RUN: opt -passes=indvars < %s2; PR9424: Attempt to use a SCEVCouldNotCompute object!3; The inner loop computes the Step and Start of the outer loop.4; Call that Vexit. The outer End value is max(2,Vexit), because5; the condition "icmp %4 < 2" does not guard the outer loop.6; SCEV knows that Vexit has range [2,4], so End == Vexit == Start.7; Now we have ExactBECount == 0. However, MinStart == 2 and MaxEnd == 4.8; Since the stride is variable and may wrap, we cannot compute9; MaxBECount. SCEV should override MaxBECount with ExactBECount.10 11define void @bar() nounwind {12entry:13 %. = select i1 undef, i32 2, i32 114 br label %"5.preheader"15 16"4": ; preds = %"5.preheader", %"4"17 %0 = phi i32 [ 0, %"5.preheader" ], [ %1, %"4" ]18 %1 = add nsw i32 %0, 119 %2 = icmp sgt i32 %., %120 br i1 %2, label %"4", label %"9"21 22"9": ; preds = %"4"23 %3 = add i32 %6, 124 %4 = add i32 %3, %125 %5 = icmp slt i32 %4, 226 br i1 %5, label %"5.preheader", label %return27 28"5.preheader": ; preds = %"9", %entry29 %6 = phi i32 [ 0, %entry ], [ %4, %"9" ]30 br label %"4"31 32return: ; preds = %"9"33 ret void34}35