1 ; RUN: llc -march=amdgcn -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck -check-prefixes=GCN,GFX9 %s
2 ; RUN: llc -march=amdgcn -mcpu=gfx1010 -verify-machineinstrs < %s | FileCheck -check-prefixes=GCN,GFX10 %s
3 ; RUN: llc -march=amdgcn -mcpu=gfx1100 -verify-machineinstrs -amdgpu-enable-vopd=0 < %s | FileCheck -check-prefixes=GCN,GFX10 %s
5 ; GCN-LABEL: {{^}}test_add_lit:
6 ; GFX10: v_add_co_u32{{(_e64)?}} v{{[0-9]+}}, vcc_lo, 0x80992bff, v{{[0-9]+}}
7 ; GFX10: v_add_co_ci_u32_e32 v{{[0-9]+}}, vcc_lo, 0xe7, v{{[0-9]+}}, vcc_lo
8 ; GFX9: v_mov_b32_e32 [[C2:v[0-9]+]], 0xe7
9 ; GFX9: v_add_co_u32_e32 v{{[0-9]+}}, vcc, 0x80992bff, v{{[0-9]+}}
10 ; GFX9: v_addc_co_u32_e32 v{{[0-9]+}}, vcc, v{{[0-9]+}}, [[C2]], vcc
11 define amdgpu_kernel void @test_add_lit(ptr addrspace(1) %p) {
12 %id = tail call i32 @llvm.amdgcn.workitem.id.x()
13 %ptr = getelementptr inbounds i64, ptr addrspace(1) %p, i32 %id
14 %load = load i64, ptr addrspace(1) %ptr, align 8
15 %add = add nsw i64 %load, 994294967295
16 store i64 %add, ptr addrspace(1) %ptr, align 8
20 ; GCN-LABEL: {{^}}test_cndmask_lit:
21 ; GFX10: v_cndmask_b32_e32 v{{[0-9]+}}, 0x3039, v{{[0-9]+}}, vcc_lo
22 ; GFX9: v_mov_b32_e32 [[C:v[0-9]+]], 0x3039
23 ; GFX9: v_cndmask_b32_e32 v{{[0-9]+}}, [[C]], v{{[0-9]+}}, vcc
24 define amdgpu_kernel void @test_cndmask_lit(ptr addrspace(1) %p) {
25 %id = tail call i32 @llvm.amdgcn.workitem.id.x()
26 %n = add nuw nsw i32 %id, 1
27 %p1 = getelementptr inbounds i32, ptr addrspace(1) %p, i32 %id
28 %v1 = load i32, ptr addrspace(1) %p1, align 4
29 %p2 = getelementptr inbounds i32, ptr addrspace(1) %p, i32 %n
30 %v2 = load i32, ptr addrspace(1) %p2, align 4
31 %cmp = icmp sgt i32 %v1, 0
32 %sel = select i1 %cmp, i32 12345, i32 %v2
33 store i32 %sel, ptr addrspace(1) %p1, align 4
37 ; GCN-LABEL: {{^}}test_bfe_2lit_s:
38 ; GFX10: v_mov_b32_e32 [[C1:v[0-9]+]], 0xddd5
39 ; GFX10: v_bfe_u32 v{{[0-9]+}}, 0x3039, s{{[0-9]+}}, [[C1]]
40 ; GFX9-DAG: v_mov_b32_e32 [[C2:v[0-9]+]], 0xddd5
41 ; GFX9-DAG: s_movk_i32 [[C1:s[0-9]+]], 0x3039
42 ; GFX9: v_bfe_u32 v{{[0-9]+}}, [[C1]], v{{[0-9]+}}, [[C2]]
43 define amdgpu_kernel void @test_bfe_2lit_s(ptr addrspace(1) %p, i32 %src) {
44 %bfe = call i32 @llvm.amdgcn.ubfe.i32(i32 12345, i32 %src, i32 56789)
45 store i32 %bfe, ptr addrspace(1) %p, align 4
49 ; GCN-LABEL: {{^}}test_bfe_2lit_v:
50 ; GFX10: s_movk_i32 [[C1:s[0-9]+]], 0x3039
51 ; GFX10: v_bfe_u32 v{{[0-9]+}}, [[C1]], v{{[0-9]+}}, 0xddd5
52 ; GFX9-DAG: v_mov_b32_e32 [[C2:v[0-9]+]], 0xddd5
53 ; GFX9-DAG: s_movk_i32 [[C1:s[0-9]+]], 0x3039
54 ; GFX9: v_bfe_u32 v{{[0-9]+}}, [[C1]], v{{[0-9]+}}, [[C2]]
55 define amdgpu_kernel void @test_bfe_2lit_v(ptr addrspace(1) %p) {
56 %id = tail call i32 @llvm.amdgcn.workitem.id.x()
57 %ptr = getelementptr inbounds i32, ptr addrspace(1) %p, i32 %id
58 %load = load i32, ptr addrspace(1) %ptr, align 4
59 %bfe = call i32 @llvm.amdgcn.ubfe.i32(i32 12345, i32 %load, i32 56789)
60 store i32 %bfe, ptr addrspace(1) %ptr, align 4
64 declare i32 @llvm.amdgcn.workitem.id.x()
65 declare i32 @llvm.amdgcn.ubfe.i32(i32, i32, i32)