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 -1
31 ; CHECK-NEXT: Loop %loop2: symbolic max backedge-taken count is -1
32 ; CHECK-NEXT: Loop %loop2: Unpredictable predicated backedge-taken count.
33 ; CHECK-NEXT: Loop %loop3: backedge-taken count is false
34 ; CHECK-NEXT: Loop %loop3: constant max backedge-taken count is false
35 ; CHECK-NEXT: Loop %loop3: symbolic max backedge-taken count is false
36 ; CHECK-NEXT: Loop %loop3: Predicated backedge-taken count is false
37 ; CHECK-NEXT: Predicates:
38 ; CHECK-NEXT: Loop %loop3: Trip multiple is 1
39 ; CHECK-NEXT: Loop %loop.header: <multiple exits> Unpredictable backedge-taken count.
40 ; CHECK-NEXT: Loop %loop.header: Unpredictable constant max backedge-taken count.
41 ; CHECK-NEXT: Loop %loop.header: Unpredictable symbolic max backedge-taken count.
42 ; CHECK-NEXT: Loop %loop.header: Unpredictable predicated backedge-taken count.
48 %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]
52 %iv2 = phi i32 [ %iv, %loop.header ], [ %iv2.next, %loop2 ]
53 %iv2.next = add i32 %iv2, 1
55 %cmp = icmp slt i32 %iv2, %v
56 br i1 %cmp, label %loop2, label %loop2.end
59 %iv2.ext = sext i32 %iv2 to i64
63 %iv3 = phi i64 [ %iv2.ext, %loop2.end ], [ %iv3.next, %loop3 ]
64 %iv3.next = add nsw i64 %iv3, 1
65 br i1 false, label %loop3, label %loop.latch
68 %iv.next = trunc i64 %iv3 to i32