1; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
2; RUN: opt < %s -analyze -enable-new-pm=0 -scalar-evolution | FileCheck %s
3; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck %s
4
5source_filename = "input.cpp"
6target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
7
8; Function Attrs: nofree
9define i8* @FSE_decompress_usingDTable(i8* %arg, i32 %arg1, i32 %arg2, i32 %arg3) local_unnamed_addr #0 {
10; CHECK-LABEL: 'FSE_decompress_usingDTable'
11; CHECK-NEXT:  Classifying expressions for: @FSE_decompress_usingDTable
12; CHECK-NEXT:    %i = getelementptr inbounds i8, i8* %arg, i32 %arg2
13; CHECK-NEXT:    --> (%arg2 + %arg) U: full-set S: full-set
14; CHECK-NEXT:    %i4 = sub nsw i32 0, %arg1
15; CHECK-NEXT:    --> (-1 * %arg1) U: full-set S: full-set
16; CHECK-NEXT:    %i5 = getelementptr inbounds i8, i8* %i, i32 %i4
17; CHECK-NEXT:    --> ((-1 * %arg1) + %arg2 + %arg) U: full-set S: full-set
18; CHECK-NEXT:    %i7 = select i1 %i6, i32 %arg2, i32 %arg1
19; CHECK-NEXT:    --> ((-1 * (ptrtoint i8* %arg to i32)) + (((-1 * %arg1) + (ptrtoint i8* %arg to i32) + %arg2) umin (ptrtoint i8* %arg to i32)) + %arg1) U: full-set S: full-set
20; CHECK-NEXT:    %i8 = sub i32 %arg3, %i7
21; CHECK-NEXT:    --> ((-1 * (((-1 * %arg1) + (ptrtoint i8* %arg to i32) + %arg2) umin (ptrtoint i8* %arg to i32))) + (-1 * %arg1) + (ptrtoint i8* %arg to i32) + %arg3) U: full-set S: full-set
22; CHECK-NEXT:    %i9 = getelementptr inbounds i8, i8* %arg, i32 %i8
23; CHECK-NEXT:    --> ((-1 * (((-1 * %arg1) + (ptrtoint i8* %arg to i32) + %arg2) umin (ptrtoint i8* %arg to i32))) + (-1 * %arg1) + (ptrtoint i8* %arg to i32) + %arg3 + %arg) U: full-set S: full-set
24; CHECK-NEXT:  Determining loop execution counts for: @FSE_decompress_usingDTable
25;
26bb:
27  %i = getelementptr inbounds i8, i8* %arg, i32 %arg2
28  %i4 = sub nsw i32 0, %arg1
29  %i5 = getelementptr inbounds i8, i8* %i, i32 %i4
30  %i6 = icmp ult i8* %i5, %arg
31  %i7 = select i1 %i6, i32 %arg2, i32 %arg1
32  %i8 = sub i32 %arg3, %i7
33  %i9 = getelementptr inbounds i8, i8* %arg, i32 %i8
34  ret i8* %i9
35}
36
37define i8* @test_01(i8* %p) {
38; CHECK-LABEL: 'test_01'
39; CHECK-NEXT:  Classifying expressions for: @test_01
40; CHECK-NEXT:    %p1 = getelementptr i8, i8* %p, i32 2
41; CHECK-NEXT:    --> (2 + %p) U: full-set S: full-set
42; CHECK-NEXT:    %p2 = getelementptr i8, i8* %p, i32 1
43; CHECK-NEXT:    --> (1 + %p) U: full-set S: full-set
44; CHECK-NEXT:    %index = select i1 %cmp, i32 2, i32 1
45; CHECK-NEXT:    --> ((-1 * (ptrtoint i8* %p to i32)) + ((1 + (ptrtoint i8* %p to i32)) umax (2 + (ptrtoint i8* %p to i32)))) U: full-set S: full-set
46; CHECK-NEXT:    %neg_index = sub i32 0, %index
47; CHECK-NEXT:    --> ((-1 * ((1 + (ptrtoint i8* %p to i32)) umax (2 + (ptrtoint i8* %p to i32)))) + (ptrtoint i8* %p to i32)) U: full-set S: full-set
48; CHECK-NEXT:    %gep = getelementptr i8, i8* %p, i32 %neg_index
49; CHECK-NEXT:    --> ((-1 * ((1 + (ptrtoint i8* %p to i32)) umax (2 + (ptrtoint i8* %p to i32)))) + (ptrtoint i8* %p to i32) + %p) U: full-set S: full-set
50; CHECK-NEXT:  Determining loop execution counts for: @test_01
51;
52  %p1 = getelementptr i8, i8* %p, i32 2
53  %p2 = getelementptr i8, i8* %p, i32 1
54  %cmp = icmp ugt i8* %p1, %p2
55  %index = select i1 %cmp, i32 2, i32 1
56  %neg_index = sub i32 0, %index
57  %gep = getelementptr i8, i8* %p, i32 %neg_index
58  ret i8* %gep
59}
60
61define i8* @test_02(i8* %p) {
62; CHECK-LABEL: 'test_02'
63; CHECK-NEXT:  Classifying expressions for: @test_02
64; CHECK-NEXT:    %p1 = getelementptr i8, i8* %p, i32 2
65; CHECK-NEXT:    --> (2 + %p) U: full-set S: full-set
66; CHECK-NEXT:    %p2 = getelementptr i8, i8* %p, i32 1
67; CHECK-NEXT:    --> (1 + %p) U: full-set S: full-set
68; CHECK-NEXT:    %index = select i1 %cmp, i32 2, i32 1
69; CHECK-NEXT:    --> ((-1 * (ptrtoint i8* %p to i32)) + ((1 + (ptrtoint i8* %p to i32)) smax (2 + (ptrtoint i8* %p to i32)))) U: full-set S: full-set
70; CHECK-NEXT:    %neg_index = sub i32 0, %index
71; CHECK-NEXT:    --> ((-1 * ((1 + (ptrtoint i8* %p to i32)) smax (2 + (ptrtoint i8* %p to i32)))) + (ptrtoint i8* %p to i32)) U: full-set S: full-set
72; CHECK-NEXT:    %gep = getelementptr i8, i8* %p, i32 %neg_index
73; CHECK-NEXT:    --> ((-1 * ((1 + (ptrtoint i8* %p to i32)) smax (2 + (ptrtoint i8* %p to i32)))) + (ptrtoint i8* %p to i32) + %p) U: full-set S: full-set
74; CHECK-NEXT:  Determining loop execution counts for: @test_02
75;
76  %p1 = getelementptr i8, i8* %p, i32 2
77  %p2 = getelementptr i8, i8* %p, i32 1
78  %cmp = icmp sgt i8* %p1, %p2
79  %index = select i1 %cmp, i32 2, i32 1
80  %neg_index = sub i32 0, %index
81  %gep = getelementptr i8, i8* %p, i32 %neg_index
82  ret i8* %gep
83}
84
85define i8* @test_03(i8* %p) {
86; CHECK-LABEL: 'test_03'
87; CHECK-NEXT:  Classifying expressions for: @test_03
88; CHECK-NEXT:    %p1 = getelementptr i8, i8* %p, i32 2
89; CHECK-NEXT:    --> (2 + %p) U: full-set S: full-set
90; CHECK-NEXT:    %p2 = getelementptr i8, i8* %p, i32 1
91; CHECK-NEXT:    --> (1 + %p) U: full-set S: full-set
92; CHECK-NEXT:    %index = select i1 %cmp, i32 2, i32 1
93; CHECK-NEXT:    --> ((-1 * (ptrtoint i8* %p to i32)) + ((1 + (ptrtoint i8* %p to i32)) umin (2 + (ptrtoint i8* %p to i32)))) U: full-set S: full-set
94; CHECK-NEXT:    %neg_index = sub i32 0, %index
95; CHECK-NEXT:    --> ((-1 * ((1 + (ptrtoint i8* %p to i32)) umin (2 + (ptrtoint i8* %p to i32)))) + (ptrtoint i8* %p to i32)) U: full-set S: full-set
96; CHECK-NEXT:    %gep = getelementptr i8, i8* %p, i32 %neg_index
97; CHECK-NEXT:    --> ((-1 * ((1 + (ptrtoint i8* %p to i32)) umin (2 + (ptrtoint i8* %p to i32)))) + (ptrtoint i8* %p to i32) + %p) U: full-set S: full-set
98; CHECK-NEXT:  Determining loop execution counts for: @test_03
99;
100  %p1 = getelementptr i8, i8* %p, i32 2
101  %p2 = getelementptr i8, i8* %p, i32 1
102  %cmp = icmp ult i8* %p1, %p2
103  %index = select i1 %cmp, i32 2, i32 1
104  %neg_index = sub i32 0, %index
105  %gep = getelementptr i8, i8* %p, i32 %neg_index
106  ret i8* %gep
107}
108
109define i8* @test_04(i8* %p) {
110; CHECK-LABEL: 'test_04'
111; CHECK-NEXT:  Classifying expressions for: @test_04
112; CHECK-NEXT:    %p1 = getelementptr i8, i8* %p, i32 2
113; CHECK-NEXT:    --> (2 + %p) U: full-set S: full-set
114; CHECK-NEXT:    %p2 = getelementptr i8, i8* %p, i32 1
115; CHECK-NEXT:    --> (1 + %p) U: full-set S: full-set
116; CHECK-NEXT:    %index = select i1 %cmp, i32 2, i32 1
117; CHECK-NEXT:    --> ((-1 * (ptrtoint i8* %p to i32)) + ((1 + (ptrtoint i8* %p to i32)) smin (2 + (ptrtoint i8* %p to i32)))) U: full-set S: full-set
118; CHECK-NEXT:    %neg_index = sub i32 0, %index
119; CHECK-NEXT:    --> ((-1 * ((1 + (ptrtoint i8* %p to i32)) smin (2 + (ptrtoint i8* %p to i32)))) + (ptrtoint i8* %p to i32)) U: full-set S: full-set
120; CHECK-NEXT:    %gep = getelementptr i8, i8* %p, i32 %neg_index
121; CHECK-NEXT:    --> ((-1 * ((1 + (ptrtoint i8* %p to i32)) smin (2 + (ptrtoint i8* %p to i32)))) + (ptrtoint i8* %p to i32) + %p) U: full-set S: full-set
122; CHECK-NEXT:  Determining loop execution counts for: @test_04
123;
124  %p1 = getelementptr i8, i8* %p, i32 2
125  %p2 = getelementptr i8, i8* %p, i32 1
126  %cmp = icmp slt i8* %p1, %p2
127  %index = select i1 %cmp, i32 2, i32 1
128  %neg_index = sub i32 0, %index
129  %gep = getelementptr i8, i8* %p, i32 %neg_index
130  ret i8* %gep
131}
132
133attributes #0 = { nofree }
134