1; RUN: opt -S -loop-reduce < %s | FileCheck %s
2
3; Address Space 10 is non-integral. The optimizer is not allowed to use
4; ptrtoint/inttoptr instructions. Make sure that this doesn't happen
5target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128-ni:10:11:12"
6target triple = "x86_64-unknown-linux-gnu"
7
8define void @japi1__unsafe_getindex_65028(i64 addrspace(10)* %arg) {
9; CHECK-NOT: inttoptr
10; CHECK-NOT: ptrtoint
11; How exactly SCEV chooses to materialize isn't all that important, as
12; long as it doesn't try to round-trip through integers. As of this writing,
13; it emits a byte-wise gep, which is fine.
14; CHECK: getelementptr i64, i64 addrspace(10)* {{.*}}, i64 {{.*}}
15top:
16  br label %L86
17
18L86:                                              ; preds = %L86, %top
19  %i.0 = phi i64 [ 0, %top ], [ %tmp, %L86 ]
20  %tmp = add i64 %i.0, 1
21  br i1 undef, label %L86, label %if29
22
23if29:                                             ; preds = %L86
24  %tmp1 = shl i64 %tmp, 1
25  %tmp2 = add i64 %tmp1, -2
26  br label %if31
27
28if31:                                             ; preds = %if38, %if29
29  %"#temp#1.sroa.0.022" = phi i64 [ 0, %if29 ], [ %tmp3, %if38 ]
30  br label %L119
31
32L119:                                             ; preds = %L119, %if31
33  %i5.0 = phi i64 [ %"#temp#1.sroa.0.022", %if31 ], [ %tmp3, %L119 ]
34  %tmp3 = add i64 %i5.0, 1
35  br i1 undef, label %L119, label %if38
36
37if38:                                             ; preds = %L119
38  %tmp4 = add i64 %tmp2, %i5.0
39  %tmp5 = getelementptr i64, i64 addrspace(10)* %arg, i64 %tmp4
40  %tmp6 = load i64, i64 addrspace(10)* %tmp5
41  br i1 undef, label %done, label %if31
42
43done:                                             ; preds = %if38
44  ret void
45}
46