2 ; RUN: opt %s -analyze -scalar-evolution -enable-new-pm=0 -scalar-evolution-classify-expressions=0 2>&1 | FileCheck %s
4 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-unknown-linux-gnu"
7 ; A collection of tests focused on exercising logic to prove no-unsigned wrap
8 ; from mustprogress semantics of loops.
10 ; CHECK: Determining loop execution counts for: @test
11 ; CHECK: Loop %for.body: Unpredictable backedge-taken count.
12 ; CHECK: Determining loop execution counts for: @test_preinc
13 ; CHECK: Loop %for.body: Unpredictable backedge-taken count.
14 ; CHECK: Determining loop execution counts for: @test_well_defined_infinite_st
15 ; CHECK: Loop %for.body: Unpredictable backedge-taken count.
16 ; CHECK: Determining loop execution counts for: @test_well_defined_infinite_ld
17 ; CHECK: Loop %for.body: Unpredictable backedge-taken count.
18 ; CHECK: Determining loop execution counts for: @test_no_mustprogress
19 ; CHECK: Loop %for.body: Unpredictable backedge-taken count.
20 ; CHECK: Determining loop execution counts for: @test_1024
21 ; CHECK: Loop %for.body: Unpredictable backedge-taken count.
22 ; CHECK: Determining loop execution counts for: @test_uneven_divide
23 ; CHECK: Loop %for.body: backedge-taken count is (-1 + (-1431655765 * %N))
24 ; CHECK: Determining loop execution counts for: @test_non_invariant_rhs
25 ; CHECK: Loop %for.body: Unpredictable backedge-taken count.
26 ; CHECK: Determining loop execution counts for: @test_abnormal_exit
27 ; CHECK: Loop %for.body: Unpredictable backedge-taken count.
28 ; CHECK: Determining loop execution counts for: @test_other_exit
29 ; CHECK: Loop %for.body: <multiple exits> Unpredictable backedge-taken count.
31 define void @test(i32 %N) mustprogress {
36 %iv = phi i32 [ %iv.next, %for.body ], [ 0, %entry ]
37 %iv.next = add i32 %iv, 2
38 %cmp = icmp ne i32 %iv.next, %N
39 br i1 %cmp, label %for.body, label %for.cond.cleanup
45 define void @test_preinc(i32 %N) mustprogress {
50 %iv = phi i32 [ %iv.next, %for.body ], [ 0, %entry ]
51 %iv.next = add i32 %iv, 2
52 %cmp = icmp ne i32 %iv, %N
53 br i1 %cmp, label %for.body, label %for.cond.cleanup
60 @G = external global i32
62 define void @test_well_defined_infinite_st(i32 %N) mustprogress {
67 %iv = phi i32 [ %iv.next, %for.body ], [ 0, %entry ]
68 %iv.next = add i32 %iv, 2
69 store volatile i32 0, i32* @G
70 %cmp = icmp ne i32 %iv.next, %N
71 br i1 %cmp, label %for.body, label %for.cond.cleanup
77 define void @test_well_defined_infinite_ld(i32 %N) mustprogress {
82 %iv = phi i32 [ %iv.next, %for.body ], [ 0, %entry ]
83 %iv.next = add i32 %iv, 2
84 %val = load volatile i32, i32* @G
85 %cmp = icmp ne i32 %iv.next, %N
86 br i1 %cmp, label %for.body, label %for.cond.cleanup
92 define void @test_no_mustprogress(i32 %N) {
97 %iv = phi i32 [ %iv.next, %for.body ], [ 0, %entry ]
98 %iv.next = add i32 %iv, 2
99 %cmp = icmp ne i32 %iv.next, %N
100 br i1 %cmp, label %for.body, label %for.cond.cleanup
108 define void @test_1024(i32 %N) mustprogress {
113 %iv = phi i32 [ %iv.next, %for.body ], [ 0, %entry ]
114 %iv.next = add i32 %iv, 1024
115 %cmp = icmp ne i32 %iv.next, %N
116 br i1 %cmp, label %for.body, label %for.cond.cleanup
122 define void @test_uneven_divide(i32 %N) mustprogress {
127 %iv = phi i32 [ %iv.next, %for.body ], [ 0, %entry ]
128 %iv.next = add i32 %iv, 3
129 %cmp = icmp ne i32 %iv.next, %N
130 br i1 %cmp, label %for.body, label %for.cond.cleanup
136 define void @test_non_invariant_rhs() mustprogress {
141 %iv = phi i32 [ %iv.next, %for.body ], [ 0, %entry ]
142 %iv.next = add i32 %iv, 2
143 %N = load i32, i32* @G
144 %cmp = icmp ne i32 %iv.next, %N
145 br i1 %cmp, label %for.body, label %for.cond.cleanup
151 declare void @mayexit()
153 define void @test_abnormal_exit(i32 %N) mustprogress {
158 %iv = phi i32 [ %iv.next, %for.body ], [ 0, %entry ]
159 %iv.next = add i32 %iv, 2
161 %cmp = icmp ne i32 %iv.next, %N
162 br i1 %cmp, label %for.body, label %for.cond.cleanup
169 define void @test_other_exit(i32 %N) mustprogress {
174 %iv = phi i32 [ %iv.next, %for.latch ], [ 0, %entry ]
175 %iv.next = add i32 %iv, 2
176 %cmp1 = icmp ne i32 %iv.next, 20
177 br i1 %cmp1, label %for.latch, label %for.cond.cleanup
180 %cmp2 = icmp ne i32 %iv.next, %N
181 br i1 %cmp2, label %for.body, label %for.cond.cleanup