2017-08-07 22:58:04 +08:00
|
|
|
; RUN: llc -amdgpu-scalarize-global-loads=false -march=amdgcn -mcpu=tahiti -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
|
2016-04-22 02:03:06 +08:00
|
|
|
|
|
|
|
; Extract the high bit of the 1st quarter
|
|
|
|
; GCN-LABEL: {{^}}v_uextract_bit_31_i128:
|
|
|
|
; GCN: buffer_load_dword [[VAL:v[0-9]+]], v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64{{$}}
|
|
|
|
|
2016-04-30 08:23:06 +08:00
|
|
|
; GCN: v_mov_b32_e32 v[[ZERO0:[0-9]+]], 0{{$}}
|
2017-05-31 00:49:24 +08:00
|
|
|
; GCN: v_mov_b32_e32 v[[ZERO1:[0-9]+]], v[[ZERO0]]{{$}}
|
2016-07-02 06:47:50 +08:00
|
|
|
; GCN: v_mov_b32_e32 v[[ZERO2:[0-9]+]], v[[ZERO0]]{{$}}
|
|
|
|
; GCN: v_lshrrev_b32_e32 v[[SHIFT:[0-9]+]], 31, [[VAL]]
|
2016-04-22 02:03:06 +08:00
|
|
|
|
2016-07-02 06:47:50 +08:00
|
|
|
; GCN: buffer_store_dwordx4 v{{\[}}[[SHIFT]]:[[ZERO2]]{{\]}}, v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64{{$}}
|
2016-04-22 02:03:06 +08:00
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @v_uextract_bit_31_i128(i128 addrspace(1)* %out, i128 addrspace(1)* %in) #1 {
|
2017-04-13 04:48:56 +08:00
|
|
|
%id.x = tail call i32 @llvm.amdgcn.workgroup.id.x()
|
2016-04-22 02:03:06 +08:00
|
|
|
%in.gep = getelementptr i128, i128 addrspace(1)* %in, i32 %id.x
|
|
|
|
%out.gep = getelementptr i128, i128 addrspace(1)* %out, i32 %id.x
|
|
|
|
%ld.64 = load i128, i128 addrspace(1)* %in.gep
|
|
|
|
%srl = lshr i128 %ld.64, 31
|
|
|
|
%bit = and i128 %srl, 1
|
|
|
|
store i128 %bit, i128 addrspace(1)* %out.gep
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; Extract the high bit of the 2nd quarter
|
|
|
|
; GCN-LABEL: {{^}}v_uextract_bit_63_i128:
|
2017-05-31 00:49:24 +08:00
|
|
|
; GCN-DAG: buffer_load_dword [[VAL:v[0-9]+]], v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64 offset:4{{$}}
|
2016-04-22 02:03:06 +08:00
|
|
|
|
2016-07-02 06:47:50 +08:00
|
|
|
; GCN-DAG: v_mov_b32_e32 v[[ZERO0:[0-9]+]], 0{{$}}
|
2016-05-03 04:07:26 +08:00
|
|
|
; GCN: v_mov_b32_e32 v[[ZERO1:[0-9]+]], v[[ZERO0]]{{$}}
|
2016-07-02 06:47:50 +08:00
|
|
|
; GCN: v_mov_b32_e32 v[[ZERO2:[0-9]+]], v[[ZERO0]]{{$}}
|
2017-05-31 00:49:24 +08:00
|
|
|
; GCN: v_mov_b32_e32 v[[ZERO3:[0-9]+]], v[[ZERO0]]{{$}}
|
2016-04-22 02:03:06 +08:00
|
|
|
; GCN-DAG: v_lshrrev_b32_e32 v[[SHIFT:[0-9]+]], 31, [[VAL]]
|
|
|
|
|
2017-05-31 00:49:24 +08:00
|
|
|
; GCN-DAG: buffer_store_dwordx4 v{{\[}}[[SHIFT]]:[[ZERO3]]{{\]}}, v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64{{$}}
|
2016-04-22 02:03:06 +08:00
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @v_uextract_bit_63_i128(i128 addrspace(1)* %out, i128 addrspace(1)* %in) #1 {
|
2016-04-22 02:03:06 +08:00
|
|
|
%id.x = tail call i32 @llvm.amdgcn.workitem.id.x()
|
|
|
|
%in.gep = getelementptr i128, i128 addrspace(1)* %in, i32 %id.x
|
|
|
|
%out.gep = getelementptr i128, i128 addrspace(1)* %out, i32 %id.x
|
|
|
|
%ld.64 = load i128, i128 addrspace(1)* %in.gep
|
|
|
|
%srl = lshr i128 %ld.64, 63
|
|
|
|
%bit = and i128 %srl, 1
|
|
|
|
store i128 %bit, i128 addrspace(1)* %out.gep
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; Extract the high bit of the 3rd quarter
|
|
|
|
; GCN-LABEL: {{^}}v_uextract_bit_95_i128:
|
|
|
|
; GCN: buffer_load_dword [[VAL:v[0-9]+]], v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64 offset:8{{$}}
|
|
|
|
|
2016-07-02 06:47:50 +08:00
|
|
|
; GCN-DAG: v_mov_b32_e32 v[[ZERO0:[0-9]+]], 0{{$}}
|
2017-05-31 00:49:24 +08:00
|
|
|
; GCN: v_mov_b32_e32 v[[ZERO1:[0-9]+]], v[[ZERO0]]{{$}}
|
2016-07-02 06:47:50 +08:00
|
|
|
; GCN: v_mov_b32_e32 v[[ZERO2:[0-9]+]], v[[ZERO0]]{{$}}
|
2016-04-22 02:03:06 +08:00
|
|
|
; GCN-DAG: v_lshrrev_b32_e32 v[[SHIFT:[0-9]+]], 31, [[VAL]]
|
|
|
|
|
2016-07-02 06:47:50 +08:00
|
|
|
; GCN-DAG: buffer_store_dwordx4 v{{\[}}[[SHIFT]]:[[ZERO2]]{{\]}}, v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64{{$}}
|
2016-04-22 02:03:06 +08:00
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @v_uextract_bit_95_i128(i128 addrspace(1)* %out, i128 addrspace(1)* %in) #1 {
|
2017-04-13 04:48:56 +08:00
|
|
|
%id.x = tail call i32 @llvm.amdgcn.workgroup.id.x()
|
2016-04-22 02:03:06 +08:00
|
|
|
%in.gep = getelementptr i128, i128 addrspace(1)* %in, i32 %id.x
|
|
|
|
%out.gep = getelementptr i128, i128 addrspace(1)* %out, i32 %id.x
|
|
|
|
%ld.64 = load i128, i128 addrspace(1)* %in.gep
|
|
|
|
%srl = lshr i128 %ld.64, 95
|
|
|
|
%bit = and i128 %srl, 1
|
|
|
|
store i128 %bit, i128 addrspace(1)* %out.gep
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; Extract the high bit of the 4th quarter
|
|
|
|
; GCN-LABEL: {{^}}v_uextract_bit_127_i128:
|
2017-05-31 00:49:24 +08:00
|
|
|
; GCN-DAG: buffer_load_dword [[VAL:v[0-9]+]], v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64 offset:12{{$}}
|
2016-04-22 02:03:06 +08:00
|
|
|
|
2017-05-31 00:49:24 +08:00
|
|
|
; GCN-DAG: v_mov_b32_e32 v[[ZERO0:[0-9]+]], 0{{$}}
|
2016-05-03 04:07:26 +08:00
|
|
|
; GCN: v_mov_b32_e32 v[[ZERO1:[0-9]+]], v[[ZERO0]]{{$}}
|
2016-07-02 06:47:50 +08:00
|
|
|
; GCN: v_mov_b32_e32 v[[ZERO2:[0-9]+]], v[[ZERO0]]{{$}}
|
2017-05-31 00:49:24 +08:00
|
|
|
; GCN: v_mov_b32_e32 v[[ZERO3:[0-9]+]], v[[ZERO0]]{{$}}
|
2016-04-22 02:03:06 +08:00
|
|
|
; GCN-DAG: v_lshrrev_b32_e32 v[[SHIFT:[0-9]+]], 31, [[VAL]]
|
|
|
|
|
2017-05-31 00:49:24 +08:00
|
|
|
; GCN-DAG: buffer_store_dwordx4 v{{\[}}[[SHIFT]]:[[ZERO3]]{{\]}}, v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64{{$}}
|
2016-04-22 02:03:06 +08:00
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @v_uextract_bit_127_i128(i128 addrspace(1)* %out, i128 addrspace(1)* %in) #1 {
|
2016-04-22 02:03:06 +08:00
|
|
|
%id.x = tail call i32 @llvm.amdgcn.workitem.id.x()
|
|
|
|
%in.gep = getelementptr i128, i128 addrspace(1)* %in, i32 %id.x
|
|
|
|
%out.gep = getelementptr i128, i128 addrspace(1)* %out, i32 %id.x
|
|
|
|
%ld.64 = load i128, i128 addrspace(1)* %in.gep
|
|
|
|
%srl = lshr i128 %ld.64, 127
|
|
|
|
%bit = and i128 %srl, 1
|
|
|
|
store i128 %bit, i128 addrspace(1)* %out.gep
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; Spans more than 2 dword boundaries
|
|
|
|
; GCN-LABEL: {{^}}v_uextract_bit_34_100_i128:
|
2017-05-31 00:49:24 +08:00
|
|
|
; GCN-DAG: buffer_load_dwordx4 v{{\[}}[[VAL0:[0-9]+]]:[[VAL3:[0-9]+]]{{\]}}, v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64{{$}}
|
2016-04-22 02:03:06 +08:00
|
|
|
|
2016-07-02 06:47:50 +08:00
|
|
|
; GCN-DAG: v_lshl_b64 v{{\[}}[[SHLLO:[0-9]+]]:[[SHLHI:[0-9]+]]{{\]}}, v{{\[[0-9]+:[0-9]+\]}}, 30
|
|
|
|
; GCN-DAG: v_lshrrev_b32_e32 v[[ELT1PART:[0-9]+]], 2, v{{[[0-9]+}}
|
2016-04-22 02:03:06 +08:00
|
|
|
; GCN-DAG: v_bfe_u32 v[[ELT2PART:[0-9]+]], v[[VAL3]], 2, 2{{$}}
|
|
|
|
; GCN-DAG: v_mov_b32_e32 v[[ZERO:[0-9]+]], 0{{$}}
|
2017-07-11 03:53:57 +08:00
|
|
|
; GCN-DAG: v_or_b32_e32 v[[OR0:[0-9]+]], v[[ELT1PART]], v[[SHLLO]]
|
2017-05-31 00:49:24 +08:00
|
|
|
; GCN-DAG: v_mov_b32_e32 v[[ZERO1:[0-9]+]], v[[ZERO]]{{$}}
|
2016-04-22 02:03:06 +08:00
|
|
|
|
2017-05-31 00:49:24 +08:00
|
|
|
; GCN-DAG: buffer_store_dwordx4 v{{\[}}[[OR0]]:[[ZERO1]]{{\]}}, v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64{{$}}
|
2016-04-22 02:03:06 +08:00
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @v_uextract_bit_34_100_i128(i128 addrspace(1)* %out, i128 addrspace(1)* %in) #1 {
|
2016-04-22 02:03:06 +08:00
|
|
|
%id.x = tail call i32 @llvm.amdgcn.workitem.id.x()
|
|
|
|
%in.gep = getelementptr i128, i128 addrspace(1)* %in, i32 %id.x
|
|
|
|
%out.gep = getelementptr i128, i128 addrspace(1)* %out, i32 %id.x
|
|
|
|
%ld.64 = load i128, i128 addrspace(1)* %in.gep
|
|
|
|
%srl = lshr i128 %ld.64, 34
|
|
|
|
%bit = and i128 %srl, 73786976294838206463
|
|
|
|
store i128 %bit, i128 addrspace(1)* %out.gep
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
declare i32 @llvm.amdgcn.workitem.id.x() #0
|
|
|
|
|
2017-04-13 04:48:56 +08:00
|
|
|
declare i32 @llvm.amdgcn.workgroup.id.x() #0
|
|
|
|
|
2016-04-22 02:03:06 +08:00
|
|
|
attributes #0 = { nounwind readnone }
|
|
|
|
attributes #1 = { nounwind }
|