Skip to content

Commit 44920e8

Browse files
committed
[AMDGPU] Disable sub-dword scralar loads IR widening
These will be widened in the DAG. In the meanwhile early widening prevents otherwise possible vectorization of such loads. Differential Revision: https://reviews.llvm.org/D77835
1 parent f62335b commit 44920e8

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static cl::opt<bool> WidenLoads(
5757
"amdgpu-codegenprepare-widen-constant-loads",
5858
cl::desc("Widen sub-dword constant address space loads in AMDGPUCodeGenPrepare"),
5959
cl::ReallyHidden,
60-
cl::init(true));
60+
cl::init(false));
6161

6262
static cl::opt<bool> UseMul24Intrin(
6363
"amdgpu-codegenprepare-mul24",
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
2+
3+
; GCN-LABEL: {{^}}load_idx_idy:
4+
; GCN-NOT: global_load
5+
; GCN: s_load_dword [[ID_XY:s[0-9]+]], s[4:5], 0x4
6+
; GCN-NOT: global_load
7+
; GCN: s_lshr_b32 [[ID_Y:s[0-9]+]], [[ID_XY]], 16
8+
; GCN: s_add_i32 [[ID_SUM:s[0-9]+]], [[ID_Y]], [[ID_XY]]
9+
; GCN: s_and_b32 s{{[0-9]+}}, [[ID_SUM]], 0xffff
10+
define protected amdgpu_kernel void @load_idx_idy(i32 addrspace(1)* %out) {
11+
entry:
12+
%disp = tail call align 4 dereferenceable(64) i8 addrspace(4)* @llvm.amdgcn.dispatch.ptr()
13+
%gep_x = getelementptr i8, i8 addrspace(4)* %disp, i64 4
14+
%gep_x.cast = bitcast i8 addrspace(4)* %gep_x to i16 addrspace(4)*
15+
%id_x = load i16, i16 addrspace(4)* %gep_x.cast, align 4, !invariant.load !0 ; load workgroup size x
16+
%gep_y = getelementptr i8, i8 addrspace(4)* %disp, i64 6
17+
%gep_y.cast = bitcast i8 addrspace(4)* %gep_y to i16 addrspace(4)*
18+
%id_y = load i16, i16 addrspace(4)* %gep_y.cast, align 2, !invariant.load !0 ; load workgroup size y
19+
%add = add nuw nsw i16 %id_y, %id_x
20+
%conv = zext i16 %add to i32
21+
store i32 %conv, i32 addrspace(1)* %out, align 4
22+
ret void
23+
}
24+
25+
declare i8 addrspace(4)* @llvm.amdgcn.dispatch.ptr()
26+
27+
!0 = !{!0}

llvm/test/CodeGen/AMDGPU/widen_extending_scalar_loads.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: opt -S -mtriple=amdgcn-- -amdgpu-codegenprepare < %s | FileCheck -check-prefix=OPT %s
1+
; RUN: opt -S -mtriple=amdgcn-- -amdgpu-codegenprepare -amdgpu-codegenprepare-widen-constant-loads < %s | FileCheck -check-prefix=OPT %s
22

33
declare i8 addrspace(4)* @llvm.amdgcn.dispatch.ptr() #0
44

0 commit comments

Comments
 (0)