2017-11-13 07:53:44 +08:00
|
|
|
; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefix=SI -check-prefix=FUNC %s
|
|
|
|
; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefix=SI -check-prefix=FUNC %s
|
2014-12-22 00:48:42 +08:00
|
|
|
|
2016-10-07 22:22:58 +08:00
|
|
|
declare i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
|
|
|
|
|
2014-12-22 00:48:42 +08:00
|
|
|
; FUNC-LABEL {{^}}sextload_i1_to_i32_trunc_cmp_eq_0:
|
|
|
|
; SI: buffer_load_ubyte [[LOAD:v[0-9]+]]
|
|
|
|
; SI: v_and_b32_e32 [[TMP:v[0-9]+]], 1, [[LOAD]]
|
2016-09-30 09:50:20 +08:00
|
|
|
; SI: v_cmp_eq_u32_e32 vcc, 0, [[TMP]]{{$}}
|
2014-12-22 00:48:42 +08:00
|
|
|
; SI: v_cndmask_b32_e64
|
|
|
|
; SI: buffer_store_byte
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @sextload_i1_to_i32_trunc_cmp_eq_0(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind {
|
2015-02-28 05:17:42 +08:00
|
|
|
%load = load i1, i1 addrspace(1)* %in
|
2014-12-22 00:48:42 +08:00
|
|
|
%ext = sext i1 %load to i32
|
|
|
|
%cmp = icmp eq i32 %ext, 0
|
|
|
|
store i1 %cmp, i1 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; FIXME: The negate should be inverting the compare.
|
|
|
|
; FUNC-LABEL: {{^}}zextload_i1_to_i32_trunc_cmp_eq_0:
|
|
|
|
; SI: buffer_load_ubyte [[LOAD:v[0-9]+]]
|
|
|
|
; SI: v_and_b32_e32 [[TMP:v[0-9]+]], 1, [[LOAD]]
|
2016-09-30 09:50:20 +08:00
|
|
|
; SI: v_cmp_eq_u32_e32 vcc, 1, [[TMP]]{{$}}
|
2015-03-24 02:45:30 +08:00
|
|
|
; SI-NEXT: s_xor_b64 [[NEG:s\[[0-9]+:[0-9]+\]]], vcc, -1
|
2014-12-22 00:48:42 +08:00
|
|
|
; SI-NEXT: v_cndmask_b32_e64 [[RESULT:v[0-9]+]], 0, 1, [[NEG]]
|
2016-03-31 00:35:09 +08:00
|
|
|
; SI: buffer_store_byte [[RESULT]]
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @zextload_i1_to_i32_trunc_cmp_eq_0(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind {
|
2015-02-28 05:17:42 +08:00
|
|
|
%load = load i1, i1 addrspace(1)* %in
|
2014-12-22 00:48:42 +08:00
|
|
|
%ext = zext i1 %load to i32
|
|
|
|
%cmp = icmp eq i32 %ext, 0
|
|
|
|
store i1 %cmp, i1 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; FUNC-LABEL: {{^}}sextload_i1_to_i32_trunc_cmp_eq_1:
|
|
|
|
; SI: v_mov_b32_e32 [[RESULT:v[0-9]+]], 0{{$}}
|
2015-02-05 07:14:18 +08:00
|
|
|
; SI: buffer_store_byte [[RESULT]]
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @sextload_i1_to_i32_trunc_cmp_eq_1(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind {
|
2015-02-28 05:17:42 +08:00
|
|
|
%load = load i1, i1 addrspace(1)* %in
|
2014-12-22 00:48:42 +08:00
|
|
|
%ext = sext i1 %load to i32
|
|
|
|
%cmp = icmp eq i32 %ext, 1
|
|
|
|
store i1 %cmp, i1 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; FUNC-LABEL: {{^}}zextload_i1_to_i32_trunc_cmp_eq_1:
|
|
|
|
; SI: buffer_load_ubyte [[LOAD:v[0-9]+]]
|
|
|
|
; SI: v_and_b32_e32 [[RESULT:v[0-9]+]], 1, [[LOAD]]
|
2016-03-31 00:35:09 +08:00
|
|
|
; SI: buffer_store_byte [[RESULT]]
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @zextload_i1_to_i32_trunc_cmp_eq_1(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind {
|
2015-02-28 05:17:42 +08:00
|
|
|
%load = load i1, i1 addrspace(1)* %in
|
2014-12-22 00:48:42 +08:00
|
|
|
%ext = zext i1 %load to i32
|
|
|
|
%cmp = icmp eq i32 %ext, 1
|
|
|
|
store i1 %cmp, i1 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; FUNC-LABEL: {{^}}sextload_i1_to_i32_trunc_cmp_eq_neg1:
|
|
|
|
; SI: buffer_load_ubyte [[LOAD:v[0-9]+]]
|
|
|
|
; SI: v_and_b32_e32 [[RESULT:v[0-9]+]], 1, [[LOAD]]
|
2016-03-31 00:35:09 +08:00
|
|
|
; SI: buffer_store_byte [[RESULT]]
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @sextload_i1_to_i32_trunc_cmp_eq_neg1(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind {
|
2015-02-28 05:17:42 +08:00
|
|
|
%load = load i1, i1 addrspace(1)* %in
|
2014-12-22 00:48:42 +08:00
|
|
|
%ext = sext i1 %load to i32
|
|
|
|
%cmp = icmp eq i32 %ext, -1
|
|
|
|
store i1 %cmp, i1 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; FUNC-LABEL: {{^}}zextload_i1_to_i32_trunc_cmp_eq_neg1:
|
|
|
|
; SI: v_mov_b32_e32 [[RESULT:v[0-9]+]], 0{{$}}
|
2015-02-05 07:14:18 +08:00
|
|
|
; SI: buffer_store_byte [[RESULT]]
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @zextload_i1_to_i32_trunc_cmp_eq_neg1(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind {
|
2015-02-28 05:17:42 +08:00
|
|
|
%load = load i1, i1 addrspace(1)* %in
|
2014-12-22 00:48:42 +08:00
|
|
|
%ext = zext i1 %load to i32
|
|
|
|
%cmp = icmp eq i32 %ext, -1
|
|
|
|
store i1 %cmp, i1 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
; FUNC-LABEL {{^}}sextload_i1_to_i32_trunc_cmp_ne_0:
|
|
|
|
; SI: buffer_load_ubyte [[LOAD:v[0-9]+]]
|
|
|
|
; SI: v_and_b32_e32 [[TMP:v[0-9]+]], 1, [[LOAD]]
|
2016-03-31 00:35:09 +08:00
|
|
|
; SI: buffer_store_byte [[RESULT]]
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @sextload_i1_to_i32_trunc_cmp_ne_0(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind {
|
2015-02-28 05:17:42 +08:00
|
|
|
%load = load i1, i1 addrspace(1)* %in
|
2014-12-22 00:48:42 +08:00
|
|
|
%ext = sext i1 %load to i32
|
|
|
|
%cmp = icmp ne i32 %ext, 0
|
|
|
|
store i1 %cmp, i1 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; FUNC-LABEL: {{^}}zextload_i1_to_i32_trunc_cmp_ne_0:
|
|
|
|
; SI: buffer_load_ubyte [[LOAD:v[0-9]+]]
|
2017-11-13 07:53:44 +08:00
|
|
|
; SI: v_and_b32_e32 [[RESULT:v[0-9]+]], 1, [[LOAD]]
|
2016-03-31 00:35:09 +08:00
|
|
|
; SI: buffer_store_byte [[RESULT]]
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @zextload_i1_to_i32_trunc_cmp_ne_0(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind {
|
2015-02-28 05:17:42 +08:00
|
|
|
%load = load i1, i1 addrspace(1)* %in
|
2014-12-22 00:48:42 +08:00
|
|
|
%ext = zext i1 %load to i32
|
|
|
|
%cmp = icmp ne i32 %ext, 0
|
|
|
|
store i1 %cmp, i1 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; FUNC-LABEL: {{^}}sextload_i1_to_i32_trunc_cmp_ne_1:
|
|
|
|
; SI: v_mov_b32_e32 [[RESULT:v[0-9]+]], 1{{$}}
|
2015-02-05 07:14:18 +08:00
|
|
|
; SI: buffer_store_byte [[RESULT]]
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @sextload_i1_to_i32_trunc_cmp_ne_1(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind {
|
2015-02-28 05:17:42 +08:00
|
|
|
%load = load i1, i1 addrspace(1)* %in
|
2014-12-22 00:48:42 +08:00
|
|
|
%ext = sext i1 %load to i32
|
|
|
|
%cmp = icmp ne i32 %ext, 1
|
|
|
|
store i1 %cmp, i1 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; FUNC-LABEL: {{^}}zextload_i1_to_i32_trunc_cmp_ne_1:
|
|
|
|
; SI: buffer_load_ubyte [[LOAD:v[0-9]+]]
|
|
|
|
; SI: v_and_b32_e32 [[TMP:v[0-9]+]], 1, [[LOAD]]
|
2016-09-30 09:50:20 +08:00
|
|
|
; SI: v_cmp_eq_u32_e32 vcc, 1, [[TMP]]{{$}}
|
2015-03-24 02:45:30 +08:00
|
|
|
; SI-NEXT: s_xor_b64 [[NEG:s\[[0-9]+:[0-9]+\]]], vcc, -1
|
2014-12-22 00:48:42 +08:00
|
|
|
; SI-NEXT: v_cndmask_b32_e64 [[RESULT:v[0-9]+]], 0, 1, [[NEG]]
|
2016-03-31 00:35:09 +08:00
|
|
|
; SI: buffer_store_byte [[RESULT]]
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @zextload_i1_to_i32_trunc_cmp_ne_1(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind {
|
2015-02-28 05:17:42 +08:00
|
|
|
%load = load i1, i1 addrspace(1)* %in
|
2014-12-22 00:48:42 +08:00
|
|
|
%ext = zext i1 %load to i32
|
|
|
|
%cmp = icmp ne i32 %ext, 1
|
|
|
|
store i1 %cmp, i1 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; FIXME: This should be one compare.
|
|
|
|
; FUNC-LABEL: {{^}}sextload_i1_to_i32_trunc_cmp_ne_neg1:
|
|
|
|
; XSI: buffer_load_ubyte [[LOAD:v[0-9]+]]
|
|
|
|
; XSI: v_and_b32_e32 [[TMP:v[0-9]+]], 1, [[LOAD]]
|
2016-09-30 09:50:20 +08:00
|
|
|
; XSI: v_cmp_eq_u32_e64 [[CMP0:s\[[0-9]+:[0-9]+\]]], [[TMP]], 0{{$}}
|
2014-12-22 00:48:42 +08:00
|
|
|
; XSI-NEXT: v_cndmask_b32_e64 [[RESULT:v[0-9]+]], 0, 1, [[CMP0]]
|
|
|
|
; XSI-NEXT: buffer_store_byte [[RESULT]]
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @sextload_i1_to_i32_trunc_cmp_ne_neg1(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind {
|
2015-02-28 05:17:42 +08:00
|
|
|
%load = load i1, i1 addrspace(1)* %in
|
2014-12-22 00:48:42 +08:00
|
|
|
%ext = sext i1 %load to i32
|
|
|
|
%cmp = icmp ne i32 %ext, -1
|
|
|
|
store i1 %cmp, i1 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; FUNC-LABEL: {{^}}zextload_i1_to_i32_trunc_cmp_ne_neg1:
|
|
|
|
; SI: v_mov_b32_e32 [[RESULT:v[0-9]+]], 1{{$}}
|
2015-02-05 07:14:18 +08:00
|
|
|
; SI: buffer_store_byte [[RESULT]]
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @zextload_i1_to_i32_trunc_cmp_ne_neg1(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind {
|
2015-02-28 05:17:42 +08:00
|
|
|
%load = load i1, i1 addrspace(1)* %in
|
2014-12-22 00:48:42 +08:00
|
|
|
%ext = zext i1 %load to i32
|
|
|
|
%cmp = icmp ne i32 %ext, -1
|
|
|
|
store i1 %cmp, i1 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2016-10-07 22:22:58 +08:00
|
|
|
; FIXME: Need to handle non-uniform case for function below (load without gep).
|
2014-12-22 00:48:42 +08:00
|
|
|
; FUNC-LABEL: {{^}}masked_load_i1_to_i32_trunc_cmp_ne_neg1:
|
2016-10-07 22:22:58 +08:00
|
|
|
; SI: {{buffer|flat}}_load_sbyte [[LOAD:v[0-9]+]]
|
2016-09-30 09:50:20 +08:00
|
|
|
; SI: v_cmp_ne_u32_e32 vcc, -1, [[LOAD]]{{$}}
|
2014-12-22 00:48:42 +08:00
|
|
|
; SI-NEXT: v_cndmask_b32_e64
|
2016-10-07 22:22:58 +08:00
|
|
|
; SI: {{buffer|flat}}_store_byte
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @masked_load_i1_to_i32_trunc_cmp_ne_neg1(i1 addrspace(1)* %out, i8 addrspace(1)* %in) nounwind {
|
2016-10-07 22:22:58 +08:00
|
|
|
%tid.x = call i32 @llvm.amdgcn.workitem.id.x()
|
|
|
|
%in.ptr = getelementptr i8, i8 addrspace(1)* %in, i32 %tid.x
|
|
|
|
%load = load i8, i8 addrspace(1)* %in.ptr
|
2014-12-22 00:48:42 +08:00
|
|
|
%masked = and i8 %load, 255
|
|
|
|
%ext = sext i8 %masked to i32
|
|
|
|
%cmp = icmp ne i32 %ext, -1
|
|
|
|
store i1 %cmp, i1 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|