blob: 3f220c40841298383e91f125897271b0c296cfe3 [file] [log] [blame]
Tom Stellard115a6152016-11-10 16:02:37 +00001; RUN: llc -march=amdgcn -mcpu=verde -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=SI %s
Matt Arsenault7aad8fd2017-01-24 22:02:15 +00002; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=VI %s
Tom Stellardf16d38c2014-02-13 23:34:13 +00003
Tom Stellard115a6152016-11-10 16:02:37 +00004declare i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
5declare i32 @llvm.amdgcn.workitem.id.y() nounwind readnone
6
7; GCN-LABEL: {{^}}anyext_i1_i32:
8; GCN: v_cndmask_b32_e64
Matt Arsenault3dbeefa2017-03-21 21:39:51 +00009define amdgpu_kernel void @anyext_i1_i32(i32 addrspace(1)* %out, i32 %cond) {
Tom Stellardf16d38c2014-02-13 23:34:13 +000010entry:
Tom Stellard115a6152016-11-10 16:02:37 +000011 %tmp = icmp eq i32 %cond, 0
12 %tmp1 = zext i1 %tmp to i8
13 %tmp2 = xor i8 %tmp1, -1
14 %tmp3 = and i8 %tmp2, 1
15 %tmp4 = zext i8 %tmp3 to i32
16 store i32 %tmp4, i32 addrspace(1)* %out
17 ret void
18}
19
20; GCN-LABEL: {{^}}s_anyext_i16_i32:
21; VI: v_add_u16_e32 [[ADD:v[0-9]+]],
22; VI: v_xor_b32_e32 [[XOR:v[0-9]+]], -1, [[ADD]]
23; VI: v_and_b32_e32 [[AND:v[0-9]+]], 1, [[XOR]]
24; VI: buffer_store_dword [[AND]]
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000025define amdgpu_kernel void @s_anyext_i16_i32(i32 addrspace(1)* %out, i16 addrspace(1)* %a, i16 addrspace(1)* %b) {
Tom Stellard115a6152016-11-10 16:02:37 +000026entry:
27 %tid.x = call i32 @llvm.amdgcn.workitem.id.x()
28 %tid.y = call i32 @llvm.amdgcn.workitem.id.y()
29 %a.ptr = getelementptr i16, i16 addrspace(1)* %a, i32 %tid.x
30 %b.ptr = getelementptr i16, i16 addrspace(1)* %b, i32 %tid.y
31 %a.l = load i16, i16 addrspace(1)* %a.ptr
32 %b.l = load i16, i16 addrspace(1)* %b.ptr
33 %tmp = add i16 %a.l, %b.l
34 %tmp1 = trunc i16 %tmp to i8
35 %tmp2 = xor i8 %tmp1, -1
36 %tmp3 = and i8 %tmp2, 1
37 %tmp4 = zext i8 %tmp3 to i32
38 store i32 %tmp4, i32 addrspace(1)* %out
Tom Stellardf16d38c2014-02-13 23:34:13 +000039 ret void
40}