1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 4
2 ; RUN: opt -disable-output "-passes=print<scalar-evolution>" -scalar-evolution-classify-expressions=0 < %s 2>&1 | FileCheck %s
4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-unknown-linux-gnu"
10 ; CHECK-NEXT: Determining loop execution counts for: @f_0
11 ; CHECK-NEXT: Loop %for.body: backedge-taken count is i32 5
12 ; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is i32 5
13 ; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is i32 5
14 ; CHECK-NEXT: Loop %for.body: Trip multiple is 6
20 %i.05 = phi i32 [ 32, %entry ], [ %div4, %for.body ]
21 tail call void @dummy()
22 %div4 = lshr i32 %i.05, 1
23 %cmp = icmp eq i32 %div4, 0
24 br i1 %cmp, label %for.cond.cleanup, label %for.body
30 ; Do not compute exhaustive trip count based on FP libcalls, as their exact
31 ; return value may not be specified.
32 define i64 @test_fp_libcall() {
33 ; CHECK-LABEL: 'test_fp_libcall'
34 ; CHECK-NEXT: Determining loop execution counts for: @test_fp_libcall
35 ; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count.
36 ; CHECK-NEXT: Loop %loop: Unpredictable constant max backedge-taken count.
37 ; CHECK-NEXT: Loop %loop: Unpredictable symbolic max backedge-taken count.
43 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
44 %fv = phi double [ 1.000000e+00, %entry ], [ %fv.next, %loop ]
45 call void @use(double %fv)
46 %fv.next = call double @llvm.sin.f64(double %fv)
47 %iv.next = add i64 %iv, 1
48 %fcmp = fcmp une double %fv, 0x3FC6BA15EE8460B0
49 br i1 %fcmp, label %loop, label %exit
55 ; Do not compute exhaustive trip count based on FP constant folding resulting
56 ; in NaN values, as we don't specify which NaN exactly is returned.
57 define i64 @test_nan_sign() {
58 ; CHECK-LABEL: 'test_nan_sign'
59 ; CHECK-NEXT: Determining loop execution counts for: @test_nan_sign
60 ; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count.
61 ; CHECK-NEXT: Loop %loop: Unpredictable constant max backedge-taken count.
62 ; CHECK-NEXT: Loop %loop: Unpredictable symbolic max backedge-taken count.
68 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
69 %fv = phi double [ -1.000000e+00, %entry ], [ %fv.next, %loop ]
70 call void @use(double %fv)
71 %a = fsub double %fv, 0x7F86C16C16C16C16
72 %b = fadd double %a, %a
73 %fv.next = fsub double %b, %a
74 %iv.next = add i64 %iv, 1
75 %fv.bc = bitcast double %fv to i64
76 %icmp = icmp slt i64 %fv.bc, 0
77 br i1 %icmp, label %loop, label %exit
83 ; Do not compute exhaustive trip count based on FP constant folding if the
84 ; involved operation has nsz or one of the algebraic FMF flags (reassoc, arcp,
85 ; contract) set. The examples in the following are dummies and don't illustrate
86 ; real cases where FMF transforms could cause issues.
88 define i64 @test_fp_nsz() {
89 ; CHECK-LABEL: 'test_fp_nsz'
90 ; CHECK-NEXT: Determining loop execution counts for: @test_fp_nsz
91 ; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count.
92 ; CHECK-NEXT: Loop %loop: Unpredictable constant max backedge-taken count.
93 ; CHECK-NEXT: Loop %loop: Unpredictable symbolic max backedge-taken count.
99 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
100 %fv = phi double [ 1.000000e+00, %entry ], [ %fv.next, %loop ]
101 call void @use(double %fv)
102 %fv.next = fadd nsz double %fv, 1.0
103 %iv.next = add i64 %iv, 1
104 %fcmp = fcmp une double %fv, 100.0
105 br i1 %fcmp, label %loop, label %exit
111 define i64 @test_fp_reassoc() {
112 ; CHECK-LABEL: 'test_fp_reassoc'
113 ; CHECK-NEXT: Determining loop execution counts for: @test_fp_reassoc
114 ; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count.
115 ; CHECK-NEXT: Loop %loop: Unpredictable constant max backedge-taken count.
116 ; CHECK-NEXT: Loop %loop: Unpredictable symbolic max backedge-taken count.
122 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
123 %fv = phi double [ 1.000000e+00, %entry ], [ %fv.next, %loop ]
124 call void @use(double %fv)
125 %fv.next = fadd reassoc double %fv, 1.0
126 %iv.next = add i64 %iv, 1
127 %fcmp = fcmp une double %fv, 100.0
128 br i1 %fcmp, label %loop, label %exit
134 define i64 @test_fp_arcp() {
135 ; CHECK-LABEL: 'test_fp_arcp'
136 ; CHECK-NEXT: Determining loop execution counts for: @test_fp_arcp
137 ; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count.
138 ; CHECK-NEXT: Loop %loop: Unpredictable constant max backedge-taken count.
139 ; CHECK-NEXT: Loop %loop: Unpredictable symbolic max backedge-taken count.
145 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
146 %fv = phi double [ 1.000000e+00, %entry ], [ %fv.next, %loop ]
147 call void @use(double %fv)
148 %fv.next = fadd arcp double %fv, 1.0
149 %iv.next = add i64 %iv, 1
150 %fcmp = fcmp une double %fv, 100.0
151 br i1 %fcmp, label %loop, label %exit
157 define i64 @test_fp_contract() {
158 ; CHECK-LABEL: 'test_fp_contract'
159 ; CHECK-NEXT: Determining loop execution counts for: @test_fp_contract
160 ; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count.
161 ; CHECK-NEXT: Loop %loop: Unpredictable constant max backedge-taken count.
162 ; CHECK-NEXT: Loop %loop: Unpredictable symbolic max backedge-taken count.
168 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
169 %fv = phi double [ 1.000000e+00, %entry ], [ %fv.next, %loop ]
170 call void @use(double %fv)
171 %fv.next = fadd contract double %fv, 1.0
172 %iv.next = add i64 %iv, 1
173 %fcmp = fcmp une double %fv, 100.0
174 br i1 %fcmp, label %loop, label %exit
180 declare void @dummy()
181 declare void @use(double %i)
182 declare double @llvm.sin.f64(double)