1; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
2; RUN: opt < %s --data-layout="p:64:64:64:64" -S -analyze -enable-new-pm=0 -scalar-evolution | FileCheck --check-prefixes=ALL,X64,PTR64_IDX64 %s
3; RUN: opt < %s --data-layout="p:64:64:64:64" -S -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck --check-prefixes=ALL,X64,PTR64_IDX64 %s
4; RUN: opt < %s --data-layout="p:64:64:64:32" -S -analyze -enable-new-pm=0 -scalar-evolution | FileCheck --check-prefixes=ALL,X64,PTR64_IDX32 %s
5; RUN: opt < %s --data-layout="p:64:64:64:32" -S -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck --check-prefixes=ALL,X64,PTR64_IDX32 %s
6; RUN: opt < %s --data-layout="p:16:16:16:16" -S -analyze -enable-new-pm=0 -scalar-evolution | FileCheck --check-prefixes=ALL,X32,PTR16_IDX16 %s
7; RUN: opt < %s --data-layout="p:16:16:16:16" -S -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck --check-prefixes=ALL,X32,PTR16_IDX16 %s
8; RUN: opt < %s --data-layout="p:16:16:16:32" -S -analyze -enable-new-pm=0 -scalar-evolution | FileCheck --check-prefixes=ALL,X32,PTR16_IDX32 %s
9; RUN: opt < %s --data-layout="p:16:16:16:32" -S -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck --check-prefixes=ALL,X32,PTR16_IDX32 %s
10
11@global = external hidden global [0 x i8]
12
13declare void @use16(i16)
14
15define hidden i32* @trunc_ptr_to_i64(i8* %arg, i32* %arg10) {
16; PTR64_IDX64-LABEL: 'trunc_ptr_to_i64'
17; PTR64_IDX64-NEXT:  Classifying expressions for: @trunc_ptr_to_i64
18; PTR64_IDX64-NEXT:    %tmp = phi i32 [ 0, %bb ], [ %tmp18, %bb17 ]
19; PTR64_IDX64-NEXT:    --> {0,+,2}<%bb11> U: [0,-1) S: [-2147483648,2147483647) Exits: <<Unknown>> LoopDispositions: { %bb11: Computable }
20; PTR64_IDX64-NEXT:    %tmp12 = getelementptr i8, i8* %arg, i64 ptrtoint ([0 x i8]* @global to i64)
21; PTR64_IDX64-NEXT:    --> (ptrtoint ([0 x i8]* @global to i64) + %arg) U: full-set S: full-set Exits: (ptrtoint ([0 x i8]* @global to i64) + %arg) LoopDispositions: { %bb11: Invariant }
22; PTR64_IDX64-NEXT:    %tmp13 = bitcast i8* %tmp12 to i32*
23; PTR64_IDX64-NEXT:    --> (ptrtoint ([0 x i8]* @global to i64) + %arg) U: full-set S: full-set Exits: (ptrtoint ([0 x i8]* @global to i64) + %arg) LoopDispositions: { %bb11: Invariant }
24; PTR64_IDX64-NEXT:    %tmp14 = load i32, i32* %tmp13, align 4
25; PTR64_IDX64-NEXT:    --> %tmp14 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb11: Variant }
26; PTR64_IDX64-NEXT:    %tmp18 = add i32 %tmp, 2
27; PTR64_IDX64-NEXT:    --> {2,+,2}<%bb11> U: [0,-1) S: [-2147483648,2147483647) Exits: <<Unknown>> LoopDispositions: { %bb11: Computable }
28; PTR64_IDX64-NEXT:  Determining loop execution counts for: @trunc_ptr_to_i64
29; PTR64_IDX64-NEXT:  Loop %bb11: Unpredictable backedge-taken count.
30; PTR64_IDX64-NEXT:  Loop %bb11: Unpredictable max backedge-taken count.
31; PTR64_IDX64-NEXT:  Loop %bb11: Unpredictable predicated backedge-taken count.
32;
33; PTR64_IDX32-LABEL: 'trunc_ptr_to_i64'
34; PTR64_IDX32-NEXT:  Classifying expressions for: @trunc_ptr_to_i64
35; PTR64_IDX32-NEXT:    %tmp = phi i32 [ 0, %bb ], [ %tmp18, %bb17 ]
36; PTR64_IDX32-NEXT:    --> {0,+,2}<%bb11> U: [0,-1) S: [-2147483648,2147483647) Exits: <<Unknown>> LoopDispositions: { %bb11: Computable }
37; PTR64_IDX32-NEXT:    %tmp12 = getelementptr i8, i8* %arg, i64 ptrtoint ([0 x i8]* @global to i64)
38; PTR64_IDX32-NEXT:    --> ((trunc i64 ptrtoint ([0 x i8]* @global to i64) to i32) + %arg) U: full-set S: full-set Exits: ((trunc i64 ptrtoint ([0 x i8]* @global to i64) to i32) + %arg) LoopDispositions: { %bb11: Invariant }
39; PTR64_IDX32-NEXT:    %tmp13 = bitcast i8* %tmp12 to i32*
40; PTR64_IDX32-NEXT:    --> ((trunc i64 ptrtoint ([0 x i8]* @global to i64) to i32) + %arg) U: full-set S: full-set Exits: ((trunc i64 ptrtoint ([0 x i8]* @global to i64) to i32) + %arg) LoopDispositions: { %bb11: Invariant }
41; PTR64_IDX32-NEXT:    %tmp14 = load i32, i32* %tmp13, align 4
42; PTR64_IDX32-NEXT:    --> %tmp14 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb11: Variant }
43; PTR64_IDX32-NEXT:    %tmp18 = add i32 %tmp, 2
44; PTR64_IDX32-NEXT:    --> {2,+,2}<%bb11> U: [0,-1) S: [-2147483648,2147483647) Exits: <<Unknown>> LoopDispositions: { %bb11: Computable }
45; PTR64_IDX32-NEXT:  Determining loop execution counts for: @trunc_ptr_to_i64
46; PTR64_IDX32-NEXT:  Loop %bb11: Unpredictable backedge-taken count.
47; PTR64_IDX32-NEXT:  Loop %bb11: Unpredictable max backedge-taken count.
48; PTR64_IDX32-NEXT:  Loop %bb11: Unpredictable predicated backedge-taken count.
49;
50; PTR16_IDX16-LABEL: 'trunc_ptr_to_i64'
51; PTR16_IDX16-NEXT:  Classifying expressions for: @trunc_ptr_to_i64
52; PTR16_IDX16-NEXT:    %tmp = phi i32 [ 0, %bb ], [ %tmp18, %bb17 ]
53; PTR16_IDX16-NEXT:    --> {0,+,2}<%bb11> U: [0,-1) S: [-2147483648,2147483647) Exits: <<Unknown>> LoopDispositions: { %bb11: Computable }
54; PTR16_IDX16-NEXT:    %tmp12 = getelementptr i8, i8* %arg, i64 ptrtoint ([0 x i8]* @global to i64)
55; PTR16_IDX16-NEXT:    --> ((trunc i64 ptrtoint ([0 x i8]* @global to i64) to i16) + %arg) U: full-set S: full-set Exits: ((trunc i64 ptrtoint ([0 x i8]* @global to i64) to i16) + %arg) LoopDispositions: { %bb11: Invariant }
56; PTR16_IDX16-NEXT:    %tmp13 = bitcast i8* %tmp12 to i32*
57; PTR16_IDX16-NEXT:    --> ((trunc i64 ptrtoint ([0 x i8]* @global to i64) to i16) + %arg) U: full-set S: full-set Exits: ((trunc i64 ptrtoint ([0 x i8]* @global to i64) to i16) + %arg) LoopDispositions: { %bb11: Invariant }
58; PTR16_IDX16-NEXT:    %tmp14 = load i32, i32* %tmp13, align 4
59; PTR16_IDX16-NEXT:    --> %tmp14 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb11: Variant }
60; PTR16_IDX16-NEXT:    %tmp18 = add i32 %tmp, 2
61; PTR16_IDX16-NEXT:    --> {2,+,2}<%bb11> U: [0,-1) S: [-2147483648,2147483647) Exits: <<Unknown>> LoopDispositions: { %bb11: Computable }
62; PTR16_IDX16-NEXT:  Determining loop execution counts for: @trunc_ptr_to_i64
63; PTR16_IDX16-NEXT:  Loop %bb11: Unpredictable backedge-taken count.
64; PTR16_IDX16-NEXT:  Loop %bb11: Unpredictable max backedge-taken count.
65; PTR16_IDX16-NEXT:  Loop %bb11: Unpredictable predicated backedge-taken count.
66;
67; PTR16_IDX32-LABEL: 'trunc_ptr_to_i64'
68; PTR16_IDX32-NEXT:  Classifying expressions for: @trunc_ptr_to_i64
69; PTR16_IDX32-NEXT:    %tmp = phi i32 [ 0, %bb ], [ %tmp18, %bb17 ]
70; PTR16_IDX32-NEXT:    --> {0,+,2}<%bb11> U: [0,-1) S: [-2147483648,2147483647) Exits: <<Unknown>> LoopDispositions: { %bb11: Computable }
71; PTR16_IDX32-NEXT:    %tmp12 = getelementptr i8, i8* %arg, i64 ptrtoint ([0 x i8]* @global to i64)
72; PTR16_IDX32-NEXT:    --> ((trunc i64 ptrtoint ([0 x i8]* @global to i64) to i32) + %arg) U: [0,131071) S: full-set Exits: ((trunc i64 ptrtoint ([0 x i8]* @global to i64) to i32) + %arg) LoopDispositions: { %bb11: Invariant }
73; PTR16_IDX32-NEXT:    %tmp13 = bitcast i8* %tmp12 to i32*
74; PTR16_IDX32-NEXT:    --> ((trunc i64 ptrtoint ([0 x i8]* @global to i64) to i32) + %arg) U: [0,131071) S: full-set Exits: ((trunc i64 ptrtoint ([0 x i8]* @global to i64) to i32) + %arg) LoopDispositions: { %bb11: Invariant }
75; PTR16_IDX32-NEXT:    %tmp14 = load i32, i32* %tmp13, align 4
76; PTR16_IDX32-NEXT:    --> %tmp14 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb11: Variant }
77; PTR16_IDX32-NEXT:    %tmp18 = add i32 %tmp, 2
78; PTR16_IDX32-NEXT:    --> {2,+,2}<%bb11> U: [0,-1) S: [-2147483648,2147483647) Exits: <<Unknown>> LoopDispositions: { %bb11: Computable }
79; PTR16_IDX32-NEXT:  Determining loop execution counts for: @trunc_ptr_to_i64
80; PTR16_IDX32-NEXT:  Loop %bb11: Unpredictable backedge-taken count.
81; PTR16_IDX32-NEXT:  Loop %bb11: Unpredictable max backedge-taken count.
82; PTR16_IDX32-NEXT:  Loop %bb11: Unpredictable predicated backedge-taken count.
83;
84bb:
85  br label %bb11
86
87bb11:                                             ; preds = %bb17, %bb
88  %tmp = phi i32 [ 0, %bb ], [ %tmp18, %bb17 ]
89  %tmp12 = getelementptr i8, i8* %arg, i64 ptrtoint ([0 x i8]* @global to i64)
90  %tmp13 = bitcast i8* %tmp12 to i32*
91  %tmp14 = load i32, i32* %tmp13, align 4
92  %tmp15 = icmp eq i32 %tmp14, 6
93  br i1 %tmp15, label %bb16, label %bb17
94
95bb16:                                             ; preds = %bb11
96  ret i32* %arg10
97
98bb17:                                             ; preds = %bb11
99  %tmp18 = add i32 %tmp, 2
100  br label %bb11
101}
102define hidden i32* @trunc_ptr_to_i32(i8* %arg, i32* %arg10) {
103; PTR64_IDX64-LABEL: 'trunc_ptr_to_i32'
104; PTR64_IDX64-NEXT:  Classifying expressions for: @trunc_ptr_to_i32
105; PTR64_IDX64-NEXT:    %tmp = phi i32 [ 0, %bb ], [ %tmp18, %bb17 ]
106; PTR64_IDX64-NEXT:    --> {0,+,2}<%bb11> U: [0,-1) S: [-2147483648,2147483647) Exits: <<Unknown>> LoopDispositions: { %bb11: Computable }
107; PTR64_IDX64-NEXT:    %tmp12 = getelementptr i8, i8* %arg, i32 ptrtoint ([0 x i8]* @global to i32)
108; PTR64_IDX64-NEXT:    --> ((sext i32 ptrtoint ([0 x i8]* @global to i32) to i64) + %arg) U: full-set S: full-set Exits: ((sext i32 ptrtoint ([0 x i8]* @global to i32) to i64) + %arg) LoopDispositions: { %bb11: Invariant }
109; PTR64_IDX64-NEXT:    %tmp13 = bitcast i8* %tmp12 to i32*
110; PTR64_IDX64-NEXT:    --> ((sext i32 ptrtoint ([0 x i8]* @global to i32) to i64) + %arg) U: full-set S: full-set Exits: ((sext i32 ptrtoint ([0 x i8]* @global to i32) to i64) + %arg) LoopDispositions: { %bb11: Invariant }
111; PTR64_IDX64-NEXT:    %tmp14 = load i32, i32* %tmp13, align 4
112; PTR64_IDX64-NEXT:    --> %tmp14 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb11: Variant }
113; PTR64_IDX64-NEXT:    %tmp18 = add i32 %tmp, 2
114; PTR64_IDX64-NEXT:    --> {2,+,2}<%bb11> U: [0,-1) S: [-2147483648,2147483647) Exits: <<Unknown>> LoopDispositions: { %bb11: Computable }
115; PTR64_IDX64-NEXT:  Determining loop execution counts for: @trunc_ptr_to_i32
116; PTR64_IDX64-NEXT:  Loop %bb11: Unpredictable backedge-taken count.
117; PTR64_IDX64-NEXT:  Loop %bb11: Unpredictable max backedge-taken count.
118; PTR64_IDX64-NEXT:  Loop %bb11: Unpredictable predicated backedge-taken count.
119;
120; PTR64_IDX32-LABEL: 'trunc_ptr_to_i32'
121; PTR64_IDX32-NEXT:  Classifying expressions for: @trunc_ptr_to_i32
122; PTR64_IDX32-NEXT:    %tmp = phi i32 [ 0, %bb ], [ %tmp18, %bb17 ]
123; PTR64_IDX32-NEXT:    --> {0,+,2}<%bb11> U: [0,-1) S: [-2147483648,2147483647) Exits: <<Unknown>> LoopDispositions: { %bb11: Computable }
124; PTR64_IDX32-NEXT:    %tmp12 = getelementptr i8, i8* %arg, i32 ptrtoint ([0 x i8]* @global to i32)
125; PTR64_IDX32-NEXT:    --> (ptrtoint ([0 x i8]* @global to i32) + %arg) U: full-set S: full-set Exits: (ptrtoint ([0 x i8]* @global to i32) + %arg) LoopDispositions: { %bb11: Invariant }
126; PTR64_IDX32-NEXT:    %tmp13 = bitcast i8* %tmp12 to i32*
127; PTR64_IDX32-NEXT:    --> (ptrtoint ([0 x i8]* @global to i32) + %arg) U: full-set S: full-set Exits: (ptrtoint ([0 x i8]* @global to i32) + %arg) LoopDispositions: { %bb11: Invariant }
128; PTR64_IDX32-NEXT:    %tmp14 = load i32, i32* %tmp13, align 4
129; PTR64_IDX32-NEXT:    --> %tmp14 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb11: Variant }
130; PTR64_IDX32-NEXT:    %tmp18 = add i32 %tmp, 2
131; PTR64_IDX32-NEXT:    --> {2,+,2}<%bb11> U: [0,-1) S: [-2147483648,2147483647) Exits: <<Unknown>> LoopDispositions: { %bb11: Computable }
132; PTR64_IDX32-NEXT:  Determining loop execution counts for: @trunc_ptr_to_i32
133; PTR64_IDX32-NEXT:  Loop %bb11: Unpredictable backedge-taken count.
134; PTR64_IDX32-NEXT:  Loop %bb11: Unpredictable max backedge-taken count.
135; PTR64_IDX32-NEXT:  Loop %bb11: Unpredictable predicated backedge-taken count.
136;
137; PTR16_IDX16-LABEL: 'trunc_ptr_to_i32'
138; PTR16_IDX16-NEXT:  Classifying expressions for: @trunc_ptr_to_i32
139; PTR16_IDX16-NEXT:    %tmp = phi i32 [ 0, %bb ], [ %tmp18, %bb17 ]
140; PTR16_IDX16-NEXT:    --> {0,+,2}<%bb11> U: [0,-1) S: [-2147483648,2147483647) Exits: <<Unknown>> LoopDispositions: { %bb11: Computable }
141; PTR16_IDX16-NEXT:    %tmp12 = getelementptr i8, i8* %arg, i32 ptrtoint ([0 x i8]* @global to i32)
142; PTR16_IDX16-NEXT:    --> ((trunc i32 ptrtoint ([0 x i8]* @global to i32) to i16) + %arg) U: full-set S: full-set Exits: ((trunc i32 ptrtoint ([0 x i8]* @global to i32) to i16) + %arg) LoopDispositions: { %bb11: Invariant }
143; PTR16_IDX16-NEXT:    %tmp13 = bitcast i8* %tmp12 to i32*
144; PTR16_IDX16-NEXT:    --> ((trunc i32 ptrtoint ([0 x i8]* @global to i32) to i16) + %arg) U: full-set S: full-set Exits: ((trunc i32 ptrtoint ([0 x i8]* @global to i32) to i16) + %arg) LoopDispositions: { %bb11: Invariant }
145; PTR16_IDX16-NEXT:    %tmp14 = load i32, i32* %tmp13, align 4
146; PTR16_IDX16-NEXT:    --> %tmp14 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb11: Variant }
147; PTR16_IDX16-NEXT:    %tmp18 = add i32 %tmp, 2
148; PTR16_IDX16-NEXT:    --> {2,+,2}<%bb11> U: [0,-1) S: [-2147483648,2147483647) Exits: <<Unknown>> LoopDispositions: { %bb11: Computable }
149; PTR16_IDX16-NEXT:  Determining loop execution counts for: @trunc_ptr_to_i32
150; PTR16_IDX16-NEXT:  Loop %bb11: Unpredictable backedge-taken count.
151; PTR16_IDX16-NEXT:  Loop %bb11: Unpredictable max backedge-taken count.
152; PTR16_IDX16-NEXT:  Loop %bb11: Unpredictable predicated backedge-taken count.
153;
154; PTR16_IDX32-LABEL: 'trunc_ptr_to_i32'
155; PTR16_IDX32-NEXT:  Classifying expressions for: @trunc_ptr_to_i32
156; PTR16_IDX32-NEXT:    %tmp = phi i32 [ 0, %bb ], [ %tmp18, %bb17 ]
157; PTR16_IDX32-NEXT:    --> {0,+,2}<%bb11> U: [0,-1) S: [-2147483648,2147483647) Exits: <<Unknown>> LoopDispositions: { %bb11: Computable }
158; PTR16_IDX32-NEXT:    %tmp12 = getelementptr i8, i8* %arg, i32 ptrtoint ([0 x i8]* @global to i32)
159; PTR16_IDX32-NEXT:    --> (ptrtoint ([0 x i8]* @global to i32) + %arg) U: [0,131071) S: full-set Exits: (ptrtoint ([0 x i8]* @global to i32) + %arg) LoopDispositions: { %bb11: Invariant }
160; PTR16_IDX32-NEXT:    %tmp13 = bitcast i8* %tmp12 to i32*
161; PTR16_IDX32-NEXT:    --> (ptrtoint ([0 x i8]* @global to i32) + %arg) U: [0,131071) S: full-set Exits: (ptrtoint ([0 x i8]* @global to i32) + %arg) LoopDispositions: { %bb11: Invariant }
162; PTR16_IDX32-NEXT:    %tmp14 = load i32, i32* %tmp13, align 4
163; PTR16_IDX32-NEXT:    --> %tmp14 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb11: Variant }
164; PTR16_IDX32-NEXT:    %tmp18 = add i32 %tmp, 2
165; PTR16_IDX32-NEXT:    --> {2,+,2}<%bb11> U: [0,-1) S: [-2147483648,2147483647) Exits: <<Unknown>> LoopDispositions: { %bb11: Computable }
166; PTR16_IDX32-NEXT:  Determining loop execution counts for: @trunc_ptr_to_i32
167; PTR16_IDX32-NEXT:  Loop %bb11: Unpredictable backedge-taken count.
168; PTR16_IDX32-NEXT:  Loop %bb11: Unpredictable max backedge-taken count.
169; PTR16_IDX32-NEXT:  Loop %bb11: Unpredictable predicated backedge-taken count.
170;
171bb:
172  br label %bb11
173
174bb11:                                             ; preds = %bb17, %bb
175  %tmp = phi i32 [ 0, %bb ], [ %tmp18, %bb17 ]
176  %tmp12 = getelementptr i8, i8* %arg, i32 ptrtoint ([0 x i8]* @global to i32)
177  %tmp13 = bitcast i8* %tmp12 to i32*
178  %tmp14 = load i32, i32* %tmp13, align 4
179  %tmp15 = icmp eq i32 %tmp14, 6
180  br i1 %tmp15, label %bb16, label %bb17
181
182bb16:                                             ; preds = %bb11
183  ret i32* %arg10
184
185bb17:                                             ; preds = %bb11
186  %tmp18 = add i32 %tmp, 2
187  br label %bb11
188}
189define hidden i32* @trunc_ptr_to_i128(i8* %arg, i32* %arg10) {
190; PTR64_IDX64-LABEL: 'trunc_ptr_to_i128'
191; PTR64_IDX64-NEXT:  Classifying expressions for: @trunc_ptr_to_i128
192; PTR64_IDX64-NEXT:    %tmp = phi i32 [ 0, %bb ], [ %tmp18, %bb17 ]
193; PTR64_IDX64-NEXT:    --> {0,+,2}<%bb11> U: [0,-1) S: [-2147483648,2147483647) Exits: <<Unknown>> LoopDispositions: { %bb11: Computable }
194; PTR64_IDX64-NEXT:    %tmp12 = getelementptr i8, i8* %arg, i128 ptrtoint ([0 x i8]* @global to i128)
195; PTR64_IDX64-NEXT:    --> ((trunc i128 ptrtoint ([0 x i8]* @global to i128) to i64) + %arg) U: full-set S: full-set Exits: ((trunc i128 ptrtoint ([0 x i8]* @global to i128) to i64) + %arg) LoopDispositions: { %bb11: Invariant }
196; PTR64_IDX64-NEXT:    %tmp13 = bitcast i8* %tmp12 to i32*
197; PTR64_IDX64-NEXT:    --> ((trunc i128 ptrtoint ([0 x i8]* @global to i128) to i64) + %arg) U: full-set S: full-set Exits: ((trunc i128 ptrtoint ([0 x i8]* @global to i128) to i64) + %arg) LoopDispositions: { %bb11: Invariant }
198; PTR64_IDX64-NEXT:    %tmp14 = load i32, i32* %tmp13, align 4
199; PTR64_IDX64-NEXT:    --> %tmp14 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb11: Variant }
200; PTR64_IDX64-NEXT:    %tmp18 = add i32 %tmp, 2
201; PTR64_IDX64-NEXT:    --> {2,+,2}<%bb11> U: [0,-1) S: [-2147483648,2147483647) Exits: <<Unknown>> LoopDispositions: { %bb11: Computable }
202; PTR64_IDX64-NEXT:  Determining loop execution counts for: @trunc_ptr_to_i128
203; PTR64_IDX64-NEXT:  Loop %bb11: Unpredictable backedge-taken count.
204; PTR64_IDX64-NEXT:  Loop %bb11: Unpredictable max backedge-taken count.
205; PTR64_IDX64-NEXT:  Loop %bb11: Unpredictable predicated backedge-taken count.
206;
207; PTR64_IDX32-LABEL: 'trunc_ptr_to_i128'
208; PTR64_IDX32-NEXT:  Classifying expressions for: @trunc_ptr_to_i128
209; PTR64_IDX32-NEXT:    %tmp = phi i32 [ 0, %bb ], [ %tmp18, %bb17 ]
210; PTR64_IDX32-NEXT:    --> {0,+,2}<%bb11> U: [0,-1) S: [-2147483648,2147483647) Exits: <<Unknown>> LoopDispositions: { %bb11: Computable }
211; PTR64_IDX32-NEXT:    %tmp12 = getelementptr i8, i8* %arg, i128 ptrtoint ([0 x i8]* @global to i128)
212; PTR64_IDX32-NEXT:    --> ((trunc i128 ptrtoint ([0 x i8]* @global to i128) to i32) + %arg) U: full-set S: full-set Exits: ((trunc i128 ptrtoint ([0 x i8]* @global to i128) to i32) + %arg) LoopDispositions: { %bb11: Invariant }
213; PTR64_IDX32-NEXT:    %tmp13 = bitcast i8* %tmp12 to i32*
214; PTR64_IDX32-NEXT:    --> ((trunc i128 ptrtoint ([0 x i8]* @global to i128) to i32) + %arg) U: full-set S: full-set Exits: ((trunc i128 ptrtoint ([0 x i8]* @global to i128) to i32) + %arg) LoopDispositions: { %bb11: Invariant }
215; PTR64_IDX32-NEXT:    %tmp14 = load i32, i32* %tmp13, align 4
216; PTR64_IDX32-NEXT:    --> %tmp14 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb11: Variant }
217; PTR64_IDX32-NEXT:    %tmp18 = add i32 %tmp, 2
218; PTR64_IDX32-NEXT:    --> {2,+,2}<%bb11> U: [0,-1) S: [-2147483648,2147483647) Exits: <<Unknown>> LoopDispositions: { %bb11: Computable }
219; PTR64_IDX32-NEXT:  Determining loop execution counts for: @trunc_ptr_to_i128
220; PTR64_IDX32-NEXT:  Loop %bb11: Unpredictable backedge-taken count.
221; PTR64_IDX32-NEXT:  Loop %bb11: Unpredictable max backedge-taken count.
222; PTR64_IDX32-NEXT:  Loop %bb11: Unpredictable predicated backedge-taken count.
223;
224; PTR16_IDX16-LABEL: 'trunc_ptr_to_i128'
225; PTR16_IDX16-NEXT:  Classifying expressions for: @trunc_ptr_to_i128
226; PTR16_IDX16-NEXT:    %tmp = phi i32 [ 0, %bb ], [ %tmp18, %bb17 ]
227; PTR16_IDX16-NEXT:    --> {0,+,2}<%bb11> U: [0,-1) S: [-2147483648,2147483647) Exits: <<Unknown>> LoopDispositions: { %bb11: Computable }
228; PTR16_IDX16-NEXT:    %tmp12 = getelementptr i8, i8* %arg, i128 ptrtoint ([0 x i8]* @global to i128)
229; PTR16_IDX16-NEXT:    --> ((trunc i128 ptrtoint ([0 x i8]* @global to i128) to i16) + %arg) U: full-set S: full-set Exits: ((trunc i128 ptrtoint ([0 x i8]* @global to i128) to i16) + %arg) LoopDispositions: { %bb11: Invariant }
230; PTR16_IDX16-NEXT:    %tmp13 = bitcast i8* %tmp12 to i32*
231; PTR16_IDX16-NEXT:    --> ((trunc i128 ptrtoint ([0 x i8]* @global to i128) to i16) + %arg) U: full-set S: full-set Exits: ((trunc i128 ptrtoint ([0 x i8]* @global to i128) to i16) + %arg) LoopDispositions: { %bb11: Invariant }
232; PTR16_IDX16-NEXT:    %tmp14 = load i32, i32* %tmp13, align 4
233; PTR16_IDX16-NEXT:    --> %tmp14 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb11: Variant }
234; PTR16_IDX16-NEXT:    %tmp18 = add i32 %tmp, 2
235; PTR16_IDX16-NEXT:    --> {2,+,2}<%bb11> U: [0,-1) S: [-2147483648,2147483647) Exits: <<Unknown>> LoopDispositions: { %bb11: Computable }
236; PTR16_IDX16-NEXT:  Determining loop execution counts for: @trunc_ptr_to_i128
237; PTR16_IDX16-NEXT:  Loop %bb11: Unpredictable backedge-taken count.
238; PTR16_IDX16-NEXT:  Loop %bb11: Unpredictable max backedge-taken count.
239; PTR16_IDX16-NEXT:  Loop %bb11: Unpredictable predicated backedge-taken count.
240;
241; PTR16_IDX32-LABEL: 'trunc_ptr_to_i128'
242; PTR16_IDX32-NEXT:  Classifying expressions for: @trunc_ptr_to_i128
243; PTR16_IDX32-NEXT:    %tmp = phi i32 [ 0, %bb ], [ %tmp18, %bb17 ]
244; PTR16_IDX32-NEXT:    --> {0,+,2}<%bb11> U: [0,-1) S: [-2147483648,2147483647) Exits: <<Unknown>> LoopDispositions: { %bb11: Computable }
245; PTR16_IDX32-NEXT:    %tmp12 = getelementptr i8, i8* %arg, i128 ptrtoint ([0 x i8]* @global to i128)
246; PTR16_IDX32-NEXT:    --> ((trunc i128 ptrtoint ([0 x i8]* @global to i128) to i32) + %arg) U: [0,131071) S: full-set Exits: ((trunc i128 ptrtoint ([0 x i8]* @global to i128) to i32) + %arg) LoopDispositions: { %bb11: Invariant }
247; PTR16_IDX32-NEXT:    %tmp13 = bitcast i8* %tmp12 to i32*
248; PTR16_IDX32-NEXT:    --> ((trunc i128 ptrtoint ([0 x i8]* @global to i128) to i32) + %arg) U: [0,131071) S: full-set Exits: ((trunc i128 ptrtoint ([0 x i8]* @global to i128) to i32) + %arg) LoopDispositions: { %bb11: Invariant }
249; PTR16_IDX32-NEXT:    %tmp14 = load i32, i32* %tmp13, align 4
250; PTR16_IDX32-NEXT:    --> %tmp14 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb11: Variant }
251; PTR16_IDX32-NEXT:    %tmp18 = add i32 %tmp, 2
252; PTR16_IDX32-NEXT:    --> {2,+,2}<%bb11> U: [0,-1) S: [-2147483648,2147483647) Exits: <<Unknown>> LoopDispositions: { %bb11: Computable }
253; PTR16_IDX32-NEXT:  Determining loop execution counts for: @trunc_ptr_to_i128
254; PTR16_IDX32-NEXT:  Loop %bb11: Unpredictable backedge-taken count.
255; PTR16_IDX32-NEXT:  Loop %bb11: Unpredictable max backedge-taken count.
256; PTR16_IDX32-NEXT:  Loop %bb11: Unpredictable predicated backedge-taken count.
257;
258bb:
259  br label %bb11
260
261bb11:                                             ; preds = %bb17, %bb
262  %tmp = phi i32 [ 0, %bb ], [ %tmp18, %bb17 ]
263  %tmp12 = getelementptr i8, i8* %arg, i128 ptrtoint ([0 x i8]* @global to i128)
264  %tmp13 = bitcast i8* %tmp12 to i32*
265  %tmp14 = load i32, i32* %tmp13, align 4
266  %tmp15 = icmp eq i32 %tmp14, 6
267  br i1 %tmp15, label %bb16, label %bb17
268
269bb16:                                             ; preds = %bb11
270  ret i32* %arg10
271
272bb17:                                             ; preds = %bb11
273  %tmp18 = add i32 %tmp, 2
274  br label %bb11
275}
276
277define void @zext_ptr_to_i32(i32 %arg, i32 %arg6) {
278; X64-LABEL: 'zext_ptr_to_i32'
279; X64-NEXT:  Classifying expressions for: @zext_ptr_to_i32
280; X64-NEXT:    %tmp = sub i32 %arg, ptrtoint ([0 x i8]* @global to i32)
281; X64-NEXT:    --> ((-1 * ptrtoint ([0 x i8]* @global to i32)) + %arg) U: full-set S: full-set Exits: ((-1 * ptrtoint ([0 x i8]* @global to i32)) + %arg) LoopDispositions: { %bb7: Invariant }
282; X64-NEXT:    %tmp9 = select i1 %tmp8, i16 0, i16 1
283; X64-NEXT:    --> %tmp9 U: [0,2) S: [-2,2) Exits: <<Unknown>> LoopDispositions: { %bb7: Variant }
284; X64-NEXT:  Determining loop execution counts for: @zext_ptr_to_i32
285; X64-NEXT:  Loop %bb7: Unpredictable backedge-taken count.
286; X64-NEXT:  Loop %bb7: Unpredictable max backedge-taken count.
287; X64-NEXT:  Loop %bb7: Unpredictable predicated backedge-taken count.
288;
289; X32-LABEL: 'zext_ptr_to_i32'
290; X32-NEXT:  Classifying expressions for: @zext_ptr_to_i32
291; X32-NEXT:    %tmp = sub i32 %arg, ptrtoint ([0 x i8]* @global to i32)
292; X32-NEXT:    --> ((-1 * ptrtoint ([0 x i8]* @global to i32))<nsw> + %arg) U: full-set S: full-set Exits: ((-1 * ptrtoint ([0 x i8]* @global to i32))<nsw> + %arg) LoopDispositions: { %bb7: Invariant }
293; X32-NEXT:    %tmp9 = select i1 %tmp8, i16 0, i16 1
294; X32-NEXT:    --> %tmp9 U: [0,2) S: [-2,2) Exits: <<Unknown>> LoopDispositions: { %bb7: Variant }
295; X32-NEXT:  Determining loop execution counts for: @zext_ptr_to_i32
296; X32-NEXT:  Loop %bb7: Unpredictable backedge-taken count.
297; X32-NEXT:  Loop %bb7: Unpredictable max backedge-taken count.
298; X32-NEXT:  Loop %bb7: Unpredictable predicated backedge-taken count.
299;
300bb:
301  br label %bb7
302
303bb7:                                              ; preds = %bb7, %bb
304  %tmp = sub i32 %arg, ptrtoint ([0 x i8]* @global to i32)
305  %tmp8 = icmp eq i32 %tmp, %arg6
306  %tmp9 = select i1 %tmp8, i16 0, i16 1
307  call void @use16(i16 %tmp9)
308  br i1 %tmp8, label %bb7, label %bb10
309
310bb10:                                             ; preds = %bb7
311  ret void
312}
313
314define void @sext_to_i32(i32 %arg, i32 %arg6) {
315; ALL-LABEL: 'sext_to_i32'
316; ALL-NEXT:  Classifying expressions for: @sext_to_i32
317; ALL-NEXT:    %tmp = sub i32 %arg, sext (i16 ptrtoint ([0 x i8]* @global to i16) to i32)
318; ALL-NEXT:    --> ((-1 * (sext i16 ptrtoint ([0 x i8]* @global to i16) to i32))<nsw> + %arg) U: full-set S: full-set Exits: ((-1 * (sext i16 ptrtoint ([0 x i8]* @global to i16) to i32))<nsw> + %arg) LoopDispositions: { %bb7: Invariant }
319; ALL-NEXT:    %tmp9 = select i1 %tmp8, i16 0, i16 1
320; ALL-NEXT:    --> %tmp9 U: [0,2) S: [-2,2) Exits: <<Unknown>> LoopDispositions: { %bb7: Variant }
321; ALL-NEXT:  Determining loop execution counts for: @sext_to_i32
322; ALL-NEXT:  Loop %bb7: Unpredictable backedge-taken count.
323; ALL-NEXT:  Loop %bb7: Unpredictable max backedge-taken count.
324; ALL-NEXT:  Loop %bb7: Unpredictable predicated backedge-taken count.
325;
326bb:
327  br label %bb7
328
329bb7:                                              ; preds = %bb7, %bb
330  %tmp = sub i32 %arg, sext (i16 ptrtoint ([0 x i8]* @global to i16) to i32)
331  %tmp8 = icmp eq i32 %tmp, %arg6
332  %tmp9 = select i1 %tmp8, i16 0, i16 1
333  call void @use16(i16 %tmp9)
334  br i1 %tmp8, label %bb7, label %bb10
335
336bb10:                                             ; preds = %bb7
337  ret void
338}
339
340define i64 @sext_like_noop(i32 %n) {
341; X64-LABEL: 'sext_like_noop'
342; X64-NEXT:  Classifying expressions for: @sext_like_noop
343; X64-NEXT:    %ii = sext i32 %i to i64
344; X64-NEXT:    --> (sext i32 {1,+,1}<nuw><%for.body> to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648) --> (sext i32 (-1 + ptrtoint (i64 (i32)* @sext_like_noop to i32)) to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648)
345; X64-NEXT:    %div = sdiv i64 55555, %ii
346; X64-NEXT:    --> %div U: full-set S: full-set --> sdiv (i64 55555, i64 sext (i32 add (i32 ptrtoint (i64 (i32)* @sext_like_noop to i32), i32 -1) to i64)) U: full-set S: full-set
347; X64-NEXT:    %i = phi i32 [ %inc, %for.body ], [ 1, %entry ]
348; X64-NEXT:    --> {1,+,1}<nuw><%for.body> U: [1,0) S: [1,0) Exits: (-1 + ptrtoint (i64 (i32)* @sext_like_noop to i32)) LoopDispositions: { %for.body: Computable }
349; X64-NEXT:    %inc = add nuw i32 %i, 1
350; X64-NEXT:    --> {2,+,1}<nuw><%for.body> U: [2,0) S: [2,0) Exits: ptrtoint (i64 (i32)* @sext_like_noop to i32) LoopDispositions: { %for.body: Computable }
351; X64-NEXT:  Determining loop execution counts for: @sext_like_noop
352; X64-NEXT:  Loop %for.body: backedge-taken count is (-2 + ptrtoint (i64 (i32)* @sext_like_noop to i32))
353; X64-NEXT:  Loop %for.body: max backedge-taken count is -1
354; X64-NEXT:  Loop %for.body: Predicated backedge-taken count is (-2 + ptrtoint (i64 (i32)* @sext_like_noop to i32))
355; X64-NEXT:   Predicates:
356; X64:       Loop %for.body: Trip multiple is 1
357;
358; X32-LABEL: 'sext_like_noop'
359; X32-NEXT:  Classifying expressions for: @sext_like_noop
360; X32-NEXT:    %ii = sext i32 %i to i64
361; X32-NEXT:    --> (sext i32 {1,+,1}<nuw><%for.body> to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648) --> (sext i32 (-1 + ptrtoint (i64 (i32)* @sext_like_noop to i32)) to i64) U: [-1,65535) S: [-65537,65535)
362; X32-NEXT:    %div = sdiv i64 55555, %ii
363; X32-NEXT:    --> %div U: full-set S: full-set --> sdiv (i64 55555, i64 sext (i32 add (i32 ptrtoint (i64 (i32)* @sext_like_noop to i32), i32 -1) to i64)) U: full-set S: full-set
364; X32-NEXT:    %i = phi i32 [ %inc, %for.body ], [ 1, %entry ]
365; X32-NEXT:    --> {1,+,1}<nuw><%for.body> U: [1,0) S: [1,0) Exits: (-1 + ptrtoint (i64 (i32)* @sext_like_noop to i32))<nsw> LoopDispositions: { %for.body: Computable }
366; X32-NEXT:    %inc = add nuw i32 %i, 1
367; X32-NEXT:    --> {2,+,1}<nuw><%for.body> U: [2,0) S: [2,0) Exits: ptrtoint (i64 (i32)* @sext_like_noop to i32) LoopDispositions: { %for.body: Computable }
368; X32-NEXT:  Determining loop execution counts for: @sext_like_noop
369; X32-NEXT:  Loop %for.body: backedge-taken count is (-2 + ptrtoint (i64 (i32)* @sext_like_noop to i32))<nsw>
370; X32-NEXT:  Loop %for.body: max backedge-taken count is -1
371; X32-NEXT:  Loop %for.body: Predicated backedge-taken count is (-2 + ptrtoint (i64 (i32)* @sext_like_noop to i32))<nsw>
372; X32-NEXT:   Predicates:
373; X32:       Loop %for.body: Trip multiple is 1
374;
375entry:
376  %cmp6 = icmp sgt i32 %n, 1
377  br label %for.body
378
379for.cond.cleanup:
380  %ii = sext i32 %i to i64
381  %div = sdiv i64 55555, %ii
382  ret i64 %div
383
384for.body:
385  %i = phi i32 [ %inc, %for.body ], [ 1, %entry ]
386  %inc = add nuw i32 %i, 1
387  %exitcond = icmp eq i32 %inc, ptrtoint (i64 (i32)* @sext_like_noop to i32)
388  br i1 %exitcond, label %for.cond.cleanup, label %for.body
389}
390declare void @f(i64)
391