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 ; This tests an invalidation issue during BECount calculation. %ptr1.dummy has
5 ; the same SCEV as %ptr1.next, but we should not remove a symbolic name
6 ; placeholder for %ptr1.next when invalidating SCEVs after BECount calculation.
8 define void @test(ptr %arg) {
10 ; CHECK-NEXT: Classifying expressions for: @test
11 ; CHECK-NEXT: %ptr1 = phi ptr [ %ptr1.next, %loop.latch ], [ null, %entry ]
12 ; CHECK-NEXT: --> %ptr1 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop.header: Variant, %loop2.header: Invariant }
13 ; CHECK-NEXT: %ptr2 = phi ptr [ %ptr2.next, %loop.latch ], [ null, %entry ]
14 ; CHECK-NEXT: --> %ptr2 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop.header: Variant, %loop2.header: Invariant }
15 ; CHECK-NEXT: %ptr1.next = phi ptr [ %ptr2, %loop.header ], [ %ptr1.next.next, %loop2.latch ]
16 ; CHECK-NEXT: --> {%ptr2,+,8}<nuw><%loop2.header> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop2.header: Computable, %loop.header: Variant }
17 ; CHECK-NEXT: %iv = phi i64 [ 0, %loop.header ], [ %iv.next, %loop2.latch ]
18 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop2.header> U: [0,1) S: [0,1) Exits: <<Unknown>> LoopDispositions: { %loop2.header: Computable, %loop.header: Variant }
19 ; CHECK-NEXT: %ptr1.dummy = getelementptr inbounds i64, ptr %ptr1.next, i64 0
20 ; CHECK-NEXT: --> {%ptr2,+,8}<nuw><%loop2.header> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop2.header: Computable, %loop.header: Variant }
21 ; CHECK-NEXT: %val = load i64, ptr %ptr1.dummy, align 8
22 ; CHECK-NEXT: --> %val U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop2.header: Variant, %loop.header: Variant }
23 ; CHECK-NEXT: %ptr1.next.next = getelementptr inbounds i64, ptr %ptr1.next, i64 1
24 ; CHECK-NEXT: --> {(8 + %ptr2),+,8}<nw><%loop2.header> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop2.header: Computable, %loop.header: Variant }
25 ; CHECK-NEXT: %iv.next = add i64 %iv, 1
26 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%loop2.header> U: [1,2) S: [1,2) Exits: <<Unknown>> LoopDispositions: { %loop2.header: Computable, %loop.header: Variant }
27 ; CHECK-NEXT: %ptr2.next = phi ptr [ %ptr1, %if ], [ %arg, %else ]
28 ; CHECK-NEXT: --> %ptr2.next U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop.header: Variant, %loop2.header: Invariant }
29 ; CHECK-NEXT: Determining loop execution counts for: @test
30 ; CHECK-NEXT: Loop %loop2.header: <multiple exits> Unpredictable backedge-taken count.
31 ; CHECK-NEXT: exit count for loop2.header: ***COULDNOTCOMPUTE***
32 ; CHECK-NEXT: exit count for loop2.latch: i1 false
33 ; CHECK-NEXT: Loop %loop2.header: constant max backedge-taken count is i1 false
34 ; CHECK-NEXT: Loop %loop2.header: symbolic max backedge-taken count is i1 false
35 ; CHECK-NEXT: symbolic max exit count for loop2.header: ***COULDNOTCOMPUTE***
36 ; CHECK-NEXT: symbolic max exit count for loop2.latch: i1 false
37 ; CHECK-NEXT: Loop %loop.header: Unpredictable backedge-taken count.
38 ; CHECK-NEXT: Loop %loop.header: Unpredictable constant max backedge-taken count.
39 ; CHECK-NEXT: Loop %loop.header: Unpredictable symbolic max backedge-taken count.
45 %ptr1 = phi ptr [ %ptr1.next, %loop.latch ], [ null, %entry ]
46 %ptr2 = phi ptr [ %ptr2.next, %loop.latch ], [ null, %entry ]
47 br label %loop2.header
50 %ptr1.next = phi ptr [ %ptr2, %loop.header ], [ %ptr1.next.next, %loop2.latch ]
51 %iv = phi i64 [ 0, %loop.header ], [ %iv.next, %loop2.latch ]
52 %ptr1.dummy = getelementptr inbounds i64, ptr %ptr1.next, i64 0
53 %val = load i64, ptr %ptr1.dummy, align 8
54 %cmp = icmp ne i64 %val, 0
55 br i1 %cmp, label %loop2.exit, label %loop2.latch
58 %ptr1.next.next = getelementptr inbounds i64, ptr %ptr1.next, i64 1
59 %iv.next = add i64 %iv, 1
60 br i1 true, label %return, label %loop2.header
63 %cmp2 = icmp sgt i64 %iv, 0
64 br i1 %cmp2, label %if, label %else
73 %ptr2.next = phi ptr [ %ptr1, %if ], [ %arg, %else ]