• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -analyze -scalar-evolution -scalar-evolution-max-iterations=0 | FileCheck %s
2
3; PR1101
4
5@A = weak global [1000 x i32] zeroinitializer, align 32
6
7define void @test1(i32 %N) {
8entry:
9        %"alloca point" = bitcast i32 0 to i32           ; <i32> [#uses=0]
10        br label %bb3
11
12bb:             ; preds = %bb3
13        %tmp = getelementptr [1000 x i32], [1000 x i32]* @A, i32 0, i32 %i.0          ; <i32*> [#uses=1]
14        store i32 123, i32* %tmp
15        %tmp2 = add i32 %i.0, 1         ; <i32> [#uses=1]
16        br label %bb3
17
18bb3:            ; preds = %bb, %entry
19        %i.0 = phi i32 [ 2, %entry ], [ %tmp2, %bb ]            ; <i32> [#uses=3]
20        %SQ = mul i32 %i.0, %i.0
21        %tmp4 = mul i32 %i.0, 2
22        %tmp5 = sub i32 %SQ, %tmp4
23        %tmp3 = icmp sle i32 %tmp5, 9999          ; <i1> [#uses=1]
24        br i1 %tmp3, label %bb, label %bb5
25
26bb5:            ; preds = %bb3
27        br label %return
28
29return:         ; preds = %bb5
30        ret void
31}
32; CHECK: Determining loop execution counts for: @test1
33; CHECK-NEXT: backedge-taken count is 100
34
35
36; PR10383
37; These next two used to crash.
38
39define void @test2(i1 %cmp, i64 %n) {
40entry:
41  br label %for.body1
42
43for.body1:
44  %a0.08 = phi i64 [ 0, %entry ], [ %inc512, %for.body1 ]
45  %inc512 = add i64 %a0.08, 1
46  br i1 %cmp, label %preheader, label %for.body1
47
48preheader:
49  br label %for.body2
50
51for.body2:
52  %indvar = phi i64 [ 0, %preheader ], [ %indvar.next, %for.body2 ]
53  %tmp111 = add i64 %n, %indvar
54  %tmp114 = mul i64 %a0.08, %indvar
55  %mul542 = mul i64 %tmp114, %tmp111
56  %indvar.next = add i64 %indvar, 1
57  br i1 undef, label %end, label %for.body2
58
59end:
60  ret void
61}
62; CHECK: Determining loop execution counts for: @test2
63
64define i32 @test3() {
65if.then466:
66  br i1 undef, label %for.cond539.preheader, label %for.inc479
67
68for.inc479:
69  %a2.07 = phi i32 [ %add495, %for.inc479 ], [ 0, %if.then466 ]
70  %j.36 = phi i32 [ %inc497, %for.inc479 ], [ undef, %if.then466 ]
71  %mul484 = mul nsw i32 %j.36, %j.36
72  %mul491 = mul i32 %j.36, %j.36
73  %mul493 = mul i32 %mul491, %mul484
74  %add495 = add nsw i32 %mul493, %a2.07
75  %inc497 = add nsw i32 %j.36, 1
76  br i1 undef, label %for.cond539.preheader, label %for.inc479
77
78for.cond539.preheader:
79  unreachable
80}
81; CHECK: Determining loop execution counts for: @test3
82
83; PR13489
84; We used to crash on this too.
85
86define void @test4() {
87entry:
88  br label %for.body
89
90for.body:                                         ; preds = %for.body, %entry
91  %v2.02 = phi i64 [ 2, %entry ], [ %phitmp, %for.body ]
92  %v1.01 = phi i64 [ -2, %entry ], [ %sub1, %for.body ]
93  %sub1 = sub i64 %v1.01, %v2.02
94  %phitmp = add i64 %v2.02, 2
95  %tobool = icmp eq i64 %sub1, %phitmp
96  br i1 %tobool, label %for.end, label %for.body
97
98for.end:                                          ; preds = %for.body
99  ret void
100}
101
102; CHECK: Determining loop execution counts for: @test4
103