1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
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 define amdgpu_kernel void @slsr_after_reassociate_global_geps_mubuf_max_offset(ptr addrspace(1) %out, ptr addrspace(1) noalias %arr, i32 %i) {
8 ; CHECK-LABEL: define amdgpu_kernel void @slsr_after_reassociate_global_geps_mubuf_max_offset(
9 ; CHECK-SAME: ptr addrspace(1) [[OUT:%.*]], ptr addrspace(1) noalias [[ARR:%.*]], i32 [[I:%.*]]) {
11 ; CHECK-NEXT: [[TMP0:%.*]] = sext i32 [[I]] to i64
12 ; CHECK-NEXT: [[TMP1:%.*]] = getelementptr float, ptr addrspace(1) [[ARR]], i64 [[TMP0]]
13 ; CHECK-NEXT: [[P12:%.*]] = getelementptr inbounds i8, ptr addrspace(1) [[TMP1]], i64 4092
14 ; CHECK-NEXT: [[V11:%.*]] = load i32, ptr addrspace(1) [[P12]], align 4
15 ; CHECK-NEXT: store i32 [[V11]], ptr addrspace(1) [[OUT]], align 4
16 ; CHECK-NEXT: [[TMP2:%.*]] = shl i64 [[TMP0]], 2
17 ; CHECK-NEXT: [[TMP3:%.*]] = getelementptr i8, ptr addrspace(1) [[TMP1]], i64 [[TMP2]]
18 ; CHECK-NEXT: [[P24:%.*]] = getelementptr inbounds i8, ptr addrspace(1) [[TMP3]], i64 4092
19 ; CHECK-NEXT: [[V22:%.*]] = load i32, ptr addrspace(1) [[P24]], align 4
20 ; CHECK-NEXT: store i32 [[V22]], ptr addrspace(1) [[OUT]], align 4
21 ; CHECK-NEXT: ret void
24 %i2 = shl nsw i32 %i, 1
25 %j1 = add nsw i32 %i, 1023
26 %tmp = sext i32 %j1 to i64
27 %p1 = getelementptr inbounds float, ptr addrspace(1) %arr, i64 %tmp
28 %v11 = load i32, ptr addrspace(1) %p1, align 4
29 store i32 %v11, ptr addrspace(1) %out, align 4
31 %j2 = add nsw i32 %i2, 1023
32 %tmp5 = sext i32 %j2 to i64
33 %p2 = getelementptr inbounds float, ptr addrspace(1) %arr, i64 %tmp5
34 %v22 = load i32, ptr addrspace(1) %p2, align 4
35 store i32 %v22, ptr addrspace(1) %out, align 4
40 define amdgpu_kernel void @slsr_after_reassociate_global_geps_over_mubuf_max_offset(ptr addrspace(1) %out, ptr addrspace(1) noalias %arr, i32 %i) {
41 ; CHECK-LABEL: define amdgpu_kernel void @slsr_after_reassociate_global_geps_over_mubuf_max_offset(
42 ; CHECK-SAME: ptr addrspace(1) [[OUT:%.*]], ptr addrspace(1) noalias [[ARR:%.*]], i32 [[I:%.*]]) {
44 ; CHECK-NEXT: [[J1:%.*]] = add nsw i32 [[I]], 1024
45 ; CHECK-NEXT: [[TMP:%.*]] = sext i32 [[J1]] to i64
46 ; CHECK-NEXT: [[P1:%.*]] = getelementptr inbounds float, ptr addrspace(1) [[ARR]], i64 [[TMP]]
47 ; CHECK-NEXT: [[V11:%.*]] = load i32, ptr addrspace(1) [[P1]], align 4
48 ; CHECK-NEXT: store i32 [[V11]], ptr addrspace(1) [[OUT]], align 4
49 ; CHECK-NEXT: [[J2:%.*]] = add i32 [[J1]], [[I]]
50 ; CHECK-NEXT: [[TMP5:%.*]] = sext i32 [[J2]] to i64
51 ; CHECK-NEXT: [[P2:%.*]] = getelementptr inbounds float, ptr addrspace(1) [[ARR]], i64 [[TMP5]]
52 ; CHECK-NEXT: [[V22:%.*]] = load i32, ptr addrspace(1) [[P2]], align 4
53 ; CHECK-NEXT: store i32 [[V22]], ptr addrspace(1) [[OUT]], align 4
54 ; CHECK-NEXT: ret void
57 %i2 = shl nsw i32 %i, 1
58 %j1 = add nsw i32 %i, 1024
59 %tmp = sext i32 %j1 to i64
60 %p1 = getelementptr inbounds float, ptr addrspace(1) %arr, i64 %tmp
61 %v11 = load i32, ptr addrspace(1) %p1, align 4
62 store i32 %v11, ptr addrspace(1) %out, align 4
64 %j2 = add nsw i32 %i2, 1024
65 %tmp5 = sext i32 %j2 to i64
66 %p2 = getelementptr inbounds float, ptr addrspace(1) %arr, i64 %tmp5
67 %v22 = load i32, ptr addrspace(1) %p2, align 4
68 store i32 %v22, ptr addrspace(1) %out, align 4
74 define amdgpu_kernel void @slsr_after_reassociate_lds_geps_ds_max_offset(ptr addrspace(1) %out, ptr addrspace(3) noalias %arr, i32 %i) {
75 ; CHECK-LABEL: define amdgpu_kernel void @slsr_after_reassociate_lds_geps_ds_max_offset(
76 ; CHECK-SAME: ptr addrspace(1) [[OUT:%.*]], ptr addrspace(3) noalias [[ARR:%.*]], i32 [[I:%.*]]) {
78 ; CHECK-NEXT: [[TMP0:%.*]] = getelementptr float, ptr addrspace(3) [[ARR]], i32 [[I]]
79 ; CHECK-NEXT: [[P12:%.*]] = getelementptr inbounds i8, ptr addrspace(3) [[TMP0]], i32 65532
80 ; CHECK-NEXT: [[V11:%.*]] = load i32, ptr addrspace(3) [[P12]], align 4
81 ; CHECK-NEXT: store i32 [[V11]], ptr addrspace(1) [[OUT]], align 4
82 ; CHECK-NEXT: [[TMP1:%.*]] = shl i32 [[I]], 2
83 ; CHECK-NEXT: [[TMP2:%.*]] = getelementptr i8, ptr addrspace(3) [[TMP0]], i32 [[TMP1]]
84 ; CHECK-NEXT: [[P24:%.*]] = getelementptr inbounds i8, ptr addrspace(3) [[TMP2]], i32 65532
85 ; CHECK-NEXT: [[V22:%.*]] = load i32, ptr addrspace(3) [[P24]], align 4
86 ; CHECK-NEXT: store i32 [[V22]], ptr addrspace(1) [[OUT]], align 4
87 ; CHECK-NEXT: ret void
90 %i2 = shl nsw i32 %i, 1
91 %j1 = add nsw i32 %i, 16383
92 %p1 = getelementptr inbounds float, ptr addrspace(3) %arr, i32 %j1
93 %v11 = load i32, ptr addrspace(3) %p1, align 4
94 store i32 %v11, ptr addrspace(1) %out, align 4
96 %j2 = add nsw i32 %i2, 16383
97 %p2 = getelementptr inbounds float, ptr addrspace(3) %arr, i32 %j2
98 %v22 = load i32, ptr addrspace(3) %p2, align 4
99 store i32 %v22, ptr addrspace(1) %out, align 4
104 define amdgpu_kernel void @slsr_after_reassociate_lds_geps_over_ds_max_offset(ptr addrspace(1) %out, ptr addrspace(3) noalias %arr, i32 %i) {
105 ; CHECK-LABEL: define amdgpu_kernel void @slsr_after_reassociate_lds_geps_over_ds_max_offset(
106 ; CHECK-SAME: ptr addrspace(1) [[OUT:%.*]], ptr addrspace(3) noalias [[ARR:%.*]], i32 [[I:%.*]]) {
108 ; CHECK-NEXT: [[J1:%.*]] = add nsw i32 [[I]], 16384
109 ; CHECK-NEXT: [[P1:%.*]] = getelementptr inbounds float, ptr addrspace(3) [[ARR]], i32 [[J1]]
110 ; CHECK-NEXT: [[V11:%.*]] = load i32, ptr addrspace(3) [[P1]], align 4
111 ; CHECK-NEXT: store i32 [[V11]], ptr addrspace(1) [[OUT]], align 4
112 ; CHECK-NEXT: [[J2:%.*]] = add i32 [[J1]], [[I]]
113 ; CHECK-NEXT: [[P2:%.*]] = getelementptr inbounds float, ptr addrspace(3) [[ARR]], i32 [[J2]]
114 ; CHECK-NEXT: [[V22:%.*]] = load i32, ptr addrspace(3) [[P2]], align 4
115 ; CHECK-NEXT: store i32 [[V22]], ptr addrspace(1) [[OUT]], align 4
116 ; CHECK-NEXT: ret void
119 %i2 = shl nsw i32 %i, 1
120 %j1 = add nsw i32 %i, 16384
121 %p1 = getelementptr inbounds float, ptr addrspace(3) %arr, i32 %j1
122 %v11 = load i32, ptr addrspace(3) %p1, align 4
123 store i32 %v11, ptr addrspace(1) %out, align 4
125 %j2 = add nsw i32 %i2, 16384
126 %p2 = getelementptr inbounds float, ptr addrspace(3) %arr, i32 %j2
127 %v22 = load i32, ptr addrspace(3) %p2, align 4
128 store i32 %v22, ptr addrspace(1) %out, align 4