xref: /aosp_15_r20/external/llvm/test/Analysis/ScalarEvolution/2011-03-09-ExactNoMaxBECount.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt -indvars < %s
2*9880d681SAndroid Build Coastguard Worker; PR9424: Attempt to use a SCEVCouldNotCompute object!
3*9880d681SAndroid Build Coastguard Worker; The inner loop computes the Step and Start of the outer loop.
4*9880d681SAndroid Build Coastguard Worker; Call that Vexit. The outer End value is max(2,Vexit), because
5*9880d681SAndroid Build Coastguard Worker; the condition "icmp %4 < 2" does not guard the outer loop.
6*9880d681SAndroid Build Coastguard Worker; SCEV knows that Vexit has range [2,4], so End == Vexit == Start.
7*9880d681SAndroid Build Coastguard Worker; Now we have ExactBECount == 0. However, MinStart == 2 and MaxEnd == 4.
8*9880d681SAndroid Build Coastguard Worker; Since the stride is variable and may wrap, we cannot compute
9*9880d681SAndroid Build Coastguard Worker; MaxBECount. SCEV should override MaxBECount with ExactBECount.
10*9880d681SAndroid Build Coastguard Worker
11*9880d681SAndroid Build Coastguard Workerdefine void @bar() nounwind {
12*9880d681SAndroid Build Coastguard Workerentry:
13*9880d681SAndroid Build Coastguard Worker  %. = select i1 undef, i32 2, i32 1
14*9880d681SAndroid Build Coastguard Worker  br label %"5.preheader"
15*9880d681SAndroid Build Coastguard Worker
16*9880d681SAndroid Build Coastguard Worker"4":                                              ; preds = %"5.preheader", %"4"
17*9880d681SAndroid Build Coastguard Worker  %0 = phi i32 [ 0, %"5.preheader" ], [ %1, %"4" ]
18*9880d681SAndroid Build Coastguard Worker  %1 = add nsw i32 %0, 1
19*9880d681SAndroid Build Coastguard Worker  %2 = icmp sgt i32 %., %1
20*9880d681SAndroid Build Coastguard Worker  br i1 %2, label %"4", label %"9"
21*9880d681SAndroid Build Coastguard Worker
22*9880d681SAndroid Build Coastguard Worker"9":                                              ; preds = %"4"
23*9880d681SAndroid Build Coastguard Worker  %3 = add i32 %6, 1
24*9880d681SAndroid Build Coastguard Worker  %4 = add i32 %3, %1
25*9880d681SAndroid Build Coastguard Worker  %5 = icmp slt i32 %4, 2
26*9880d681SAndroid Build Coastguard Worker  br i1 %5, label %"5.preheader", label %return
27*9880d681SAndroid Build Coastguard Worker
28*9880d681SAndroid Build Coastguard Worker"5.preheader":                                    ; preds = %"9", %entry
29*9880d681SAndroid Build Coastguard Worker  %6 = phi i32 [ 0, %entry ], [ %4, %"9" ]
30*9880d681SAndroid Build Coastguard Worker  br label %"4"
31*9880d681SAndroid Build Coastguard Worker
32*9880d681SAndroid Build Coastguard Workerreturn:                                           ; preds = %"9"
33*9880d681SAndroid Build Coastguard Worker  ret void
34*9880d681SAndroid Build Coastguard Worker}
35