1 ; RUN: opt -S -mtriple=amdgcn-- -passes=separate-const-offset-from-gep,slsr,gvn < %s | FileCheck %s
2 ; RUN: opt -S -mtriple=amdgcn-- -passes="separate-const-offset-from-gep,slsr,gvn" < %s | FileCheck %s
4 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"
7 ; CHECK-LABEL: @slsr_after_reassociate_global_geps_mubuf_max_offset(
8 ; CHECK: [[b1:%[0-9]+]] = getelementptr float, ptr addrspace(1) %arr, i64 [[bump:%[0-9]+]]
9 ; CHECK: [[b2:%[0-9]+]] = getelementptr float, ptr addrspace(1) [[b1]], i64 [[bump]]
10 define amdgpu_kernel void @slsr_after_reassociate_global_geps_mubuf_max_offset(ptr addrspace(1) %out, ptr addrspace(1) noalias %arr, i32 %i) {
12 %i2 = shl nsw i32 %i, 1
13 %j1 = add nsw i32 %i, 1023
14 %tmp = sext i32 %j1 to i64
15 %p1 = getelementptr inbounds float, ptr addrspace(1) %arr, i64 %tmp
16 %v11 = load i32, ptr addrspace(1) %p1, align 4
17 store i32 %v11, ptr addrspace(1) %out, align 4
19 %j2 = add nsw i32 %i2, 1023
20 %tmp5 = sext i32 %j2 to i64
21 %p2 = getelementptr inbounds float, ptr addrspace(1) %arr, i64 %tmp5
22 %v22 = load i32, ptr addrspace(1) %p2, align 4
23 store i32 %v22, ptr addrspace(1) %out, align 4
28 ; CHECK-LABEL: @slsr_after_reassociate_global_geps_over_mubuf_max_offset(
29 ; CHECK: %j1 = add nsw i32 %i, 1024
30 ; CHECK: %tmp = sext i32 %j1 to i64
31 ; CHECK: getelementptr inbounds float, ptr addrspace(1) %arr, i64 %tmp
32 ; CHECK: getelementptr inbounds float, ptr addrspace(1) %arr, i64 %tmp5
33 define amdgpu_kernel void @slsr_after_reassociate_global_geps_over_mubuf_max_offset(ptr addrspace(1) %out, ptr addrspace(1) noalias %arr, i32 %i) {
35 %i2 = shl nsw i32 %i, 1
36 %j1 = add nsw i32 %i, 1024
37 %tmp = sext i32 %j1 to i64
38 %p1 = getelementptr inbounds float, ptr addrspace(1) %arr, i64 %tmp
39 %v11 = load i32, ptr addrspace(1) %p1, align 4
40 store i32 %v11, ptr addrspace(1) %out, align 4
42 %j2 = add nsw i32 %i2, 1024
43 %tmp5 = sext i32 %j2 to i64
44 %p2 = getelementptr inbounds float, ptr addrspace(1) %arr, i64 %tmp5
45 %v22 = load i32, ptr addrspace(1) %p2, align 4
46 store i32 %v22, ptr addrspace(1) %out, align 4
51 ; CHECK-LABEL: @slsr_after_reassociate_lds_geps_ds_max_offset(
52 ; CHECK: [[B1:%[0-9]+]] = getelementptr float, ptr addrspace(3) %arr, i32 %i
53 ; CHECK: getelementptr inbounds float, ptr addrspace(3) [[B1]], i32 16383
55 ; CHECK: [[B2:%[0-9]+]] = getelementptr float, ptr addrspace(3) [[B1]], i32 %i
56 ; CHECK: getelementptr inbounds float, ptr addrspace(3) [[B2]], i32 16383
57 define amdgpu_kernel void @slsr_after_reassociate_lds_geps_ds_max_offset(ptr addrspace(1) %out, ptr addrspace(3) noalias %arr, i32 %i) {
59 %i2 = shl nsw i32 %i, 1
60 %j1 = add nsw i32 %i, 16383
61 %p1 = getelementptr inbounds float, ptr addrspace(3) %arr, i32 %j1
62 %v11 = load i32, ptr addrspace(3) %p1, align 4
63 store i32 %v11, ptr addrspace(1) %out, align 4
65 %j2 = add nsw i32 %i2, 16383
66 %p2 = getelementptr inbounds float, ptr addrspace(3) %arr, i32 %j2
67 %v22 = load i32, ptr addrspace(3) %p2, align 4
68 store i32 %v22, ptr addrspace(1) %out, align 4
73 ; CHECK-LABEL: @slsr_after_reassociate_lds_geps_over_ds_max_offset(
74 ; CHECK: %j1 = add nsw i32 %i, 16384
75 ; CHECK: getelementptr inbounds float, ptr addrspace(3) %arr, i32 %j1
76 ; CHECK: %j2 = add i32 %j1, %i
77 ; CHECK: getelementptr inbounds float, ptr addrspace(3) %arr, i32 %j2
78 define amdgpu_kernel void @slsr_after_reassociate_lds_geps_over_ds_max_offset(ptr addrspace(1) %out, ptr addrspace(3) noalias %arr, i32 %i) {
80 %i2 = shl nsw i32 %i, 1
81 %j1 = add nsw i32 %i, 16384
82 %p1 = getelementptr inbounds float, ptr addrspace(3) %arr, i32 %j1
83 %v11 = load i32, ptr addrspace(3) %p1, align 4
84 store i32 %v11, ptr addrspace(1) %out, align 4
86 %j2 = add nsw i32 %i2, 16384
87 %p2 = getelementptr inbounds float, ptr addrspace(3) %arr, i32 %j2
88 %v22 = load i32, ptr addrspace(3) %p2, align 4
89 store i32 %v22, ptr addrspace(1) %out, align 4