1 ; RUN: opt < %s -S -analyze -enable-new-pm=0 -scalar-evolution | FileCheck %s
2 ; RUN: opt < %s -S -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck %s
4 ; copied from flags-from-poison.ll
5 ; CHECK-LABEL: @test-add-nuw
6 ; CHECK: --> {(1 + %offset)<nuw>,+,1}<nuw><%loop> U: [1,0) S: [1,0)
7 define void @test-add-nuw(float* %input, i32 %offset, i32 %numIterations) {
11 %i = phi i32 [ %nexti, %loop ], [ 0, %entry ]
12 %nexti = add nuw i32 %i, 1
13 %index32 = add nuw i32 %nexti, %offset
14 %ptr = getelementptr inbounds float, float* %input, i32 %index32
15 %f = load float, float* %ptr, align 4
16 %exitcond = icmp eq i32 %nexti, %numIterations
17 br i1 %exitcond, label %exit, label %loop
23 ; CHECK-LABEL: @test-addrec-nuw
24 ; CHECK: --> {(1 + (10 smax %offset))<nuw>,+,1}<nuw><%loop> U: [11,0) S: [11,0)
25 define void @test-addrec-nuw(float* %input, i32 %offset, i32 %numIterations) {
27 %cmp = icmp sgt i32 %offset, 10
28 %min.10 = select i1 %cmp, i32 %offset, i32 10
31 %i = phi i32 [ %nexti, %loop ], [ 0, %entry ]
32 %nexti = add nuw i32 %i, 1
33 %index32 = add nuw i32 %nexti, %min.10
34 %ptr = getelementptr inbounds float, float* %input, i32 %index32
35 %f = load float, float* %ptr, align 4
36 %exitcond = icmp eq i32 %nexti, %numIterations
37 br i1 %exitcond, label %exit, label %loop
43 ; CHECK-LABEL: @test-addrec-nsw-start-neg-strip-neg
44 ; CHECK: --> {(-1 + (-10 smin %offset))<nsw>,+,-1}<nsw><%loop> U: [-2147483648,-10) S: [-2147483648,-10)
45 define void @test-addrec-nsw-start-neg-strip-neg(float* %input, i32 %offset, i32 %numIterations) {
47 %cmp = icmp slt i32 %offset, -10
48 %max = select i1 %cmp, i32 %offset, i32 -10
51 %i = phi i32 [ %nexti, %loop ], [ 0, %entry ]
52 %nexti = add nsw i32 %i, -1
53 %index32 = add nsw i32 %nexti, %max
54 %ptr = getelementptr inbounds float, float* %input, i32 %index32
55 %f = load float, float* %ptr, align 4
56 %exitcond = icmp eq i32 %nexti, %numIterations
57 br i1 %exitcond, label %exit, label %loop
63 ; CHECK-LABEL: @test-addrec-nsw-start-pos-strip-neg
64 ; CHECK: --> {(-1 + (10 smin %offset))<nsw>,+,-1}<nsw><%loop> U: [-2147483648,10) S: [-2147483648,10)
65 define void @test-addrec-nsw-start-pos-strip-neg(float* %input, i32 %offset, i32 %numIterations) {
67 %cmp = icmp slt i32 %offset, 10
68 %max = select i1 %cmp, i32 %offset, i32 10
71 %i = phi i32 [ %nexti, %loop ], [ 0, %entry ]
72 %nexti = add nsw i32 %i, -1
73 %index32 = add nsw i32 %nexti, %max
74 %ptr = getelementptr inbounds float, float* %input, i32 %index32
75 %f = load float, float* %ptr, align 4
76 %exitcond = icmp eq i32 %nexti, %numIterations
77 br i1 %exitcond, label %exit, label %loop
83 ; CHECK-LABEL: @test-addrec-nsw-start-pos-strip-pos
84 ; CHECK: --> {(1 + (10 smax %offset))<nuw><nsw>,+,1}<nuw><nsw><%loop> U: [11,-2147483648) S: [11,-2147483648)
85 define void @test-addrec-nsw-start-pos-strip-pos(float* %input, i32 %offset, i32 %numIterations) {
87 %cmp = icmp sgt i32 %offset, 10
88 %min = select i1 %cmp, i32 %offset, i32 10
91 %i = phi i32 [ %nexti, %loop ], [ 0, %entry ]
92 %nexti = add nsw i32 %i, 1
93 %index32 = add nsw i32 %nexti, %min
94 %ptr = getelementptr inbounds float, float* %input, i32 %index32
95 %f = load float, float* %ptr, align 4
96 %exitcond = icmp eq i32 %nexti, %numIterations
97 br i1 %exitcond, label %exit, label %loop
103 ; CHECK-LABEL: @test-addrec-nsw-start-neg-strip-pos
104 ; CHECK: --> {(1 + (-10 smax %offset))<nsw>,+,1}<nsw><%loop> U: [-9,-2147483648) S: [-9,-2147483648)
105 define void @test-addrec-nsw-start-neg-strip-pos(float* %input, i32 %offset, i32 %numIterations) {
107 %cmp = icmp sgt i32 %offset, -10
108 %min = select i1 %cmp, i32 %offset, i32 -10
111 %i = phi i32 [ %nexti, %loop ], [ 0, %entry ]
112 %nexti = add nsw i32 %i, 1
113 %index32 = add nsw i32 %nexti, %min
114 %ptr = getelementptr inbounds float, float* %input, i32 %index32
115 %f = load float, float* %ptr, align 4
116 %exitcond = icmp eq i32 %nexti, %numIterations
117 br i1 %exitcond, label %exit, label %loop