1 ; RUN: opt -S -mtriple=amdgcn-- -separate-const-offset-from-gep -slsr -gvn < %s | FileCheck %s
3 target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-p24:64:64-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
6 ; CHECK-LABEL: @slsr_after_reassociate_global_geps_mubuf_max_offset(
7 ; CHECK: [[b1:%[0-9]+]] = getelementptr float, float addrspace(1)* %arr, i64 [[bump:%[0-9]+]]
8 ; CHECK: [[b2:%[0-9]+]] = getelementptr float, float addrspace(1)* [[b1]], i64 [[bump]]
9 define amdgpu_kernel void @slsr_after_reassociate_global_geps_mubuf_max_offset(float addrspace(1)* %out, float addrspace(1)* noalias %arr, i32 %i) {
11 %i2 = shl nsw i32 %i, 1
12 %j1 = add nsw i32 %i, 1023
13 %tmp = sext i32 %j1 to i64
14 %p1 = getelementptr inbounds float, float addrspace(1)* %arr, i64 %tmp
15 %tmp3 = bitcast float addrspace(1)* %p1 to i32 addrspace(1)*
16 %v11 = load i32, i32 addrspace(1)* %tmp3, align 4
17 %tmp4 = bitcast float addrspace(1)* %out to i32 addrspace(1)*
18 store i32 %v11, i32 addrspace(1)* %tmp4, align 4
20 %j2 = add nsw i32 %i2, 1023
21 %tmp5 = sext i32 %j2 to i64
22 %p2 = getelementptr inbounds float, float addrspace(1)* %arr, i64 %tmp5
23 %tmp6 = bitcast float addrspace(1)* %p2 to i32 addrspace(1)*
24 %v22 = load i32, i32 addrspace(1)* %tmp6, align 4
25 %tmp7 = bitcast float addrspace(1)* %out to i32 addrspace(1)*
26 store i32 %v22, i32 addrspace(1)* %tmp7, align 4
31 ; CHECK-LABEL: @slsr_after_reassociate_global_geps_over_mubuf_max_offset(
32 ; CHECK: %j1 = add nsw i32 %i, 1024
33 ; CHECK: %tmp = sext i32 %j1 to i64
34 ; CHECK: getelementptr inbounds float, float addrspace(1)* %arr, i64 %tmp
35 ; CHECK: getelementptr inbounds float, float addrspace(1)* %arr, i64 %tmp5
36 define amdgpu_kernel void @slsr_after_reassociate_global_geps_over_mubuf_max_offset(float addrspace(1)* %out, float addrspace(1)* noalias %arr, i32 %i) {
38 %i2 = shl nsw i32 %i, 1
39 %j1 = add nsw i32 %i, 1024
40 %tmp = sext i32 %j1 to i64
41 %p1 = getelementptr inbounds float, float addrspace(1)* %arr, i64 %tmp
42 %tmp3 = bitcast float addrspace(1)* %p1 to i32 addrspace(1)*
43 %v11 = load i32, i32 addrspace(1)* %tmp3, align 4
44 %tmp4 = bitcast float addrspace(1)* %out to i32 addrspace(1)*
45 store i32 %v11, i32 addrspace(1)* %tmp4, align 4
47 %j2 = add nsw i32 %i2, 1024
48 %tmp5 = sext i32 %j2 to i64
49 %p2 = getelementptr inbounds float, float addrspace(1)* %arr, i64 %tmp5
50 %tmp6 = bitcast float addrspace(1)* %p2 to i32 addrspace(1)*
51 %v22 = load i32, i32 addrspace(1)* %tmp6, align 4
52 %tmp7 = bitcast float addrspace(1)* %out to i32 addrspace(1)*
53 store i32 %v22, i32 addrspace(1)* %tmp7, align 4
58 ; CHECK-LABEL: @slsr_after_reassociate_lds_geps_ds_max_offset(
59 ; CHECK: [[B1:%[0-9]+]] = getelementptr float, float addrspace(3)* %arr, i32 %i
60 ; CHECK: getelementptr inbounds float, float addrspace(3)* [[B1]], i32 16383
62 ; CHECK: [[B2:%[0-9]+]] = getelementptr float, float addrspace(3)* [[B1]], i32 %i
63 ; CHECK: getelementptr inbounds float, float addrspace(3)* [[B2]], i32 16383
64 define amdgpu_kernel void @slsr_after_reassociate_lds_geps_ds_max_offset(float addrspace(1)* %out, float addrspace(3)* noalias %arr, i32 %i) {
66 %i2 = shl nsw i32 %i, 1
67 %j1 = add nsw i32 %i, 16383
68 %p1 = getelementptr inbounds float, float addrspace(3)* %arr, i32 %j1
69 %tmp3 = bitcast float addrspace(3)* %p1 to i32 addrspace(3)*
70 %v11 = load i32, i32 addrspace(3)* %tmp3, align 4
71 %tmp4 = bitcast float addrspace(1)* %out to i32 addrspace(1)*
72 store i32 %v11, i32 addrspace(1)* %tmp4, align 4
74 %j2 = add nsw i32 %i2, 16383
75 %p2 = getelementptr inbounds float, float addrspace(3)* %arr, i32 %j2
76 %tmp6 = bitcast float addrspace(3)* %p2 to i32 addrspace(3)*
77 %v22 = load i32, i32 addrspace(3)* %tmp6, align 4
78 %tmp7 = bitcast float addrspace(1)* %out to i32 addrspace(1)*
79 store i32 %v22, i32 addrspace(1)* %tmp7, align 4
84 ; CHECK-LABEL: @slsr_after_reassociate_lds_geps_over_ds_max_offset(
85 ; CHECK: %j1 = add nsw i32 %i, 16384
86 ; CHECK: getelementptr inbounds float, float addrspace(3)* %arr, i32 %j1
87 ; CHECK: %j2 = add i32 %j1, %i
88 ; CHECK: getelementptr inbounds float, float addrspace(3)* %arr, i32 %j2
89 define amdgpu_kernel void @slsr_after_reassociate_lds_geps_over_ds_max_offset(float addrspace(1)* %out, float addrspace(3)* noalias %arr, i32 %i) {
91 %i2 = shl nsw i32 %i, 1
92 %j1 = add nsw i32 %i, 16384
93 %p1 = getelementptr inbounds float, float addrspace(3)* %arr, i32 %j1
94 %tmp3 = bitcast float addrspace(3)* %p1 to i32 addrspace(3)*
95 %v11 = load i32, i32 addrspace(3)* %tmp3, align 4
96 %tmp4 = bitcast float addrspace(1)* %out to i32 addrspace(1)*
97 store i32 %v11, i32 addrspace(1)* %tmp4, align 4
99 %j2 = add nsw i32 %i2, 16384
100 %p2 = getelementptr inbounds float, float addrspace(3)* %arr, i32 %j2
101 %tmp6 = bitcast float addrspace(3)* %p2 to i32 addrspace(3)*
102 %v22 = load i32, i32 addrspace(3)* %tmp6, align 4
103 %tmp7 = bitcast float addrspace(1)* %out to i32 addrspace(1)*
104 store i32 %v22, i32 addrspace(1)* %tmp7, align 4