1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
2 ; RUN: opt -disable-output "-passes=print<scalar-evolution>" < %s 2>&1 | FileCheck %s
4 ; In this case the %iv2 addrec is calculated and added to the value map in a
5 ; recursive call trying to calculate that same addrec. Due to lazy nowrap flag
6 ; inference, the exact SCEV calculated both times ends up being different,
7 ; though both expressions are correct. Make sure we don't assert in this case.
9 define void @test(ptr %p) {
11 ; CHECK-NEXT: Classifying expressions for: @test
12 ; CHECK-NEXT: %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]
13 ; CHECK-NEXT: --> %iv U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop.header: Variant, %loop2: Invariant, %loop3: Invariant }
14 ; CHECK-NEXT: %iv2 = phi i32 [ %iv, %loop.header ], [ %iv2.next, %loop2 ]
15 ; CHECK-NEXT: --> {%iv,+,1}<%loop2> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop2: Computable, %loop.header: Variant }
16 ; CHECK-NEXT: %iv2.next = add i32 %iv2, 1
17 ; CHECK-NEXT: --> {(1 + %iv),+,1}<%loop2> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop2: Computable, %loop.header: Variant }
18 ; CHECK-NEXT: %v = load i32, ptr %p, align 4
19 ; CHECK-NEXT: --> %v U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop2: Variant, %loop.header: Variant }
20 ; CHECK-NEXT: %iv2.ext = sext i32 %iv2 to i64
21 ; CHECK-NEXT: --> (sext i32 {%iv,+,1}<%loop2> to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648) Exits: <<Unknown>> LoopDispositions: { %loop.header: Variant, %loop2: Computable, %loop3: Invariant }
22 ; CHECK-NEXT: %iv3 = phi i64 [ %iv2.ext, %loop2.end ], [ %iv3.next, %loop3 ]
23 ; CHECK-NEXT: --> {(sext i32 {%iv,+,1}<%loop2> to i64),+,1}<nsw><%loop3> U: [-2147483648,2147483648) S: [-2147483648,2147483648) Exits: (sext i32 {%iv,+,1}<%loop2> to i64) LoopDispositions: { %loop3: Computable, %loop.header: Variant }
24 ; CHECK-NEXT: %iv3.next = add nsw i64 %iv3, 1
25 ; CHECK-NEXT: --> {(1 + (sext i32 {%iv,+,1}<%loop2> to i64))<nsw>,+,1}<nsw><%loop3> U: [-2147483647,2147483649) S: [-2147483647,2147483649) Exits: (1 + (sext i32 {%iv,+,1}<%loop2> to i64))<nsw> LoopDispositions: { %loop3: Computable, %loop.header: Variant }
26 ; CHECK-NEXT: %iv.next = trunc i64 %iv3 to i32
27 ; CHECK-NEXT: --> {{\{\{}}%iv,+,1}<%loop2>,+,1}<%loop3> U: full-set S: full-set --> {%iv,+,1}<%loop2> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop.header: Variant, %loop2: Variant, %loop3: Computable }
28 ; CHECK-NEXT: Determining loop execution counts for: @test
29 ; CHECK-NEXT: Loop %loop2: Unpredictable backedge-taken count.
30 ; CHECK-NEXT: Loop %loop2: constant max backedge-taken count is i32 -1
31 ; CHECK-NEXT: Loop %loop2: symbolic max backedge-taken count is i32 -1
32 ; CHECK-NEXT: Loop %loop3: backedge-taken count is i1 false
33 ; CHECK-NEXT: Loop %loop3: constant max backedge-taken count is i1 false
34 ; CHECK-NEXT: Loop %loop3: symbolic max backedge-taken count is i1 false
35 ; CHECK-NEXT: Loop %loop3: Trip multiple is 1
36 ; CHECK-NEXT: Loop %loop.header: <multiple exits> Unpredictable backedge-taken count.
37 ; CHECK-NEXT: Loop %loop.header: Unpredictable constant max backedge-taken count.
38 ; CHECK-NEXT: Loop %loop.header: Unpredictable symbolic max backedge-taken count.
44 %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]
48 %iv2 = phi i32 [ %iv, %loop.header ], [ %iv2.next, %loop2 ]
49 %iv2.next = add i32 %iv2, 1
51 %cmp = icmp slt i32 %iv2, %v
52 br i1 %cmp, label %loop2, label %loop2.end
55 %iv2.ext = sext i32 %iv2 to i64
59 %iv3 = phi i64 [ %iv2.ext, %loop2.end ], [ %iv3.next, %loop3 ]
60 %iv3.next = add nsw i64 %iv3, 1
61 br i1 false, label %loop3, label %loop.latch
64 %iv.next = trunc i64 %iv3 to i32