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 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
5 target triple = "i386-pc-linux-gnu"
7 @arr1 = internal unnamed_addr constant [50 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48, i32 49, i32 50], align 4
8 @arr2 = internal unnamed_addr constant [50 x i32] [i32 49, i32 48, i32 47, i32 46, i32 45, i32 44, i32 43, i32 42, i32 41, i32 40, i32 39, i32 38, i32 37, i32 36, i32 35, i32 34, i32 33, i32 32, i32 31, i32 30, i32 29, i32 28, i32 27, i32 26, i32 25, i32 24, i32 23, i32 22, i32 21, i32 20, i32 19, i32 18, i32 17, i32 16, i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0], align 4
11 define i32 @test1() nounwind readnone {
12 ; CHECK-LABEL: 'test1'
13 ; CHECK-NEXT: Classifying expressions for: @test1
14 ; CHECK-NEXT: %sum.04 = phi i32 [ 0, %entry ], [ %add2, %for.body ]
15 ; CHECK-NEXT: --> %sum.04 U: full-set S: full-set Exits: 2450 LoopDispositions: { %for.body: Variant }
16 ; CHECK-NEXT: %i.03 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
17 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%for.body> U: [0,50) S: [0,50) Exits: 49 LoopDispositions: { %for.body: Computable }
18 ; CHECK-NEXT: %arrayidx = getelementptr inbounds [50 x i32], ptr @arr1, i32 0, i32 %i.03
19 ; CHECK-NEXT: --> {@arr1,+,4}<nuw><%for.body> U: [4,-7) S: [-2147483648,2147483645) Exits: (196 + @arr1)<nuw> LoopDispositions: { %for.body: Computable }
20 ; CHECK-NEXT: %0 = load i32, ptr %arrayidx, align 4
21 ; CHECK-NEXT: --> %0 U: full-set S: full-set Exits: 50 LoopDispositions: { %for.body: Variant }
22 ; CHECK-NEXT: %arrayidx1 = getelementptr inbounds [50 x i32], ptr @arr2, i32 0, i32 %i.03
23 ; CHECK-NEXT: --> {@arr2,+,4}<nuw><%for.body> U: [4,-7) S: [-2147483648,2147483645) Exits: (196 + @arr2)<nuw> LoopDispositions: { %for.body: Computable }
24 ; CHECK-NEXT: %1 = load i32, ptr %arrayidx1, align 4
25 ; CHECK-NEXT: --> %1 U: full-set S: full-set Exits: 0 LoopDispositions: { %for.body: Variant }
26 ; CHECK-NEXT: %add = add i32 %0, %sum.04
27 ; CHECK-NEXT: --> (%0 + %sum.04) U: full-set S: full-set Exits: 2500 LoopDispositions: { %for.body: Variant }
28 ; CHECK-NEXT: %add2 = add i32 %add, %1
29 ; CHECK-NEXT: --> (%1 + %0 + %sum.04) U: full-set S: full-set Exits: 2500 LoopDispositions: { %for.body: Variant }
30 ; CHECK-NEXT: %inc = add nsw i32 %i.03, 1
31 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%for.body> U: [1,51) S: [1,51) Exits: 50 LoopDispositions: { %for.body: Computable }
32 ; CHECK-NEXT: Determining loop execution counts for: @test1
33 ; CHECK-NEXT: Loop %for.body: backedge-taken count is 49
34 ; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is 49
35 ; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is 49
36 ; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is 49
37 ; CHECK-NEXT: Predicates:
38 ; CHECK-NEXT: Loop %for.body: Trip multiple is 50
43 for.body: ; preds = %entry, %for.body
44 %sum.04 = phi i32 [ 0, %entry ], [ %add2, %for.body ]
45 %i.03 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
46 %arrayidx = getelementptr inbounds [50 x i32], ptr @arr1, i32 0, i32 %i.03
47 %0 = load i32, ptr %arrayidx, align 4
48 %arrayidx1 = getelementptr inbounds [50 x i32], ptr @arr2, i32 0, i32 %i.03
49 %1 = load i32, ptr %arrayidx1, align 4
50 %add = add i32 %0, %sum.04
51 %add2 = add i32 %add, %1
52 %inc = add nsw i32 %i.03, 1
53 %cmp = icmp eq i32 %inc, 50
54 br i1 %cmp, label %for.end, label %for.body
56 for.end: ; preds = %for.body
61 %struct.ListNode = type { ptr, i32 }
63 @node5 = internal constant { ptr, i32, [4 x i8] } { ptr @node4, i32 4, [4 x i8] undef }, align 8
64 @node4 = internal constant { ptr, i32, [4 x i8] } { ptr @node3, i32 3, [4 x i8] undef }, align 8
65 @node3 = internal constant { ptr, i32, [4 x i8] } { ptr @node2, i32 2, [4 x i8] undef }, align 8
66 @node2 = internal constant { ptr, i32, [4 x i8] } { ptr @node1, i32 1, [4 x i8] undef }, align 8
67 @node1 = internal constant { ptr, i32, [4 x i8] } { ptr null, i32 0, [4 x i8] undef }, align 8
69 define i32 @test2() nounwind uwtable readonly {
70 ; CHECK-LABEL: 'test2'
71 ; CHECK-NEXT: Classifying expressions for: @test2
72 ; CHECK-NEXT: %sum.02 = phi i32 [ 0, %entry ], [ %add, %for.body ]
73 ; CHECK-NEXT: --> %sum.02 U: full-set S: full-set Exits: 10 LoopDispositions: { %for.body: Variant }
74 ; CHECK-NEXT: %n.01 = phi ptr [ @node5, %entry ], [ %1, %for.body ]
75 ; CHECK-NEXT: --> %n.01 U: full-set S: full-set Exits: @node1 LoopDispositions: { %for.body: Variant }
76 ; CHECK-NEXT: %i = getelementptr inbounds %struct.ListNode, ptr %n.01, i64 0, i32 1
77 ; CHECK-NEXT: --> (4 + %n.01)<nuw> U: [4,0) S: [4,0) Exits: (4 + @node1)<nuw><nsw> LoopDispositions: { %for.body: Variant }
78 ; CHECK-NEXT: %0 = load i32, ptr %i, align 4
79 ; CHECK-NEXT: --> %0 U: full-set S: full-set Exits: 0 LoopDispositions: { %for.body: Variant }
80 ; CHECK-NEXT: %add = add nsw i32 %0, %sum.02
81 ; CHECK-NEXT: --> (%0 + %sum.02) U: full-set S: full-set Exits: 10 LoopDispositions: { %for.body: Variant }
82 ; CHECK-NEXT: %next = getelementptr inbounds %struct.ListNode, ptr %n.01, i64 0, i32 0
83 ; CHECK-NEXT: --> %n.01 U: full-set S: full-set Exits: @node1 LoopDispositions: { %for.body: Variant }
84 ; CHECK-NEXT: %1 = load ptr, ptr %next, align 8
85 ; CHECK-NEXT: --> %1 U: full-set S: full-set Exits: null LoopDispositions: { %for.body: Variant }
86 ; CHECK-NEXT: Determining loop execution counts for: @test2
87 ; CHECK-NEXT: Loop %for.body: backedge-taken count is 4
88 ; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is 4
89 ; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is 4
90 ; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is 4
91 ; CHECK-NEXT: Predicates:
92 ; CHECK-NEXT: Loop %for.body: Trip multiple is 5
97 for.body: ; preds = %entry, %for.body
98 %sum.02 = phi i32 [ 0, %entry ], [ %add, %for.body ]
99 %n.01 = phi ptr [ @node5, %entry ], [ %1, %for.body ]
100 %i = getelementptr inbounds %struct.ListNode, ptr %n.01, i64 0, i32 1
101 %0 = load i32, ptr %i, align 4
102 %add = add nsw i32 %0, %sum.02
103 %next = getelementptr inbounds %struct.ListNode, ptr %n.01, i64 0, i32 0
104 %1 = load ptr, ptr %next, align 8
105 %cmp = icmp eq ptr %1, null
106 br i1 %cmp, label %for.end, label %for.body
108 for.end: ; preds = %for.body