1; RUN: llc -mtriple=amdgcn---amdgiz -mcpu=kaveri -verify-machineinstrs < %s | FileCheck %s 2; 3; The original OpenCL kernel: 4; kernel void f(global int *a, int i, int j) { 5; int x[100]; 6; x[i] = 7; 7; a[0] = x[j]; 8; } 9; clang -cc1 -triple amdgcn---amdgizcl -emit-llvm -o - 10 11target datalayout = "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:32:32-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5" 12 13define amdgpu_kernel void @f(i32 addrspace(1)* nocapture %a, i32 %i, i32 %j) local_unnamed_addr #0 { 14entry: 15; CHECK: s_load_dwordx2 s[4:5], s[0:1], 0x9 16; CHECK: s_load_dwordx2 s[0:1], s[0:1], 0xb 17; CHECK: s_mov_b32 s8, SCRATCH_RSRC_DWORD0 18; CHECK: s_mov_b32 s9, SCRATCH_RSRC_DWORD1 19; CHECK: s_mov_b32 s10, -1 20; CHECK: v_mov_b32_e32 v0, 4 21; CHECK: s_waitcnt lgkmcnt(0) 22; CHECK: s_lshl_b32 s0, s0, 2 23; CHECK: v_add_i32_e32 v1, vcc, s0, v0 24; CHECK: s_lshl_b32 s0, s1, 2 25; CHECK: s_mov_b32 s11, 0xe8f000 26; CHECK: v_mov_b32_e32 v2, 7 27; CHECK: buffer_store_dword v2, v1, s[8:11], s3 offen 28; CHECK: v_add_i32_e32 v0, vcc, s0, v0 29; CHECK: s_mov_b32 s7, 0xf000 30; CHECK: s_mov_b32 s6, -1 31; CHECK: buffer_load_dword v0, v0, s[8:11], s3 offen 32; CHECK: s_waitcnt vmcnt(0) 33; CHECK: buffer_store_dword v0, off, s[4:7], 0 34; CHECK: s_endpgm 35 36 %x = alloca [100 x i32], align 4, addrspace(5) 37 %alloca.bc = bitcast [100 x i32] addrspace(5)* %x to i8 addrspace(5)* 38 call void @llvm.lifetime.start.p5i8(i64 400, i8 addrspace(5)* nonnull %alloca.bc) #0 39 %arrayidx = getelementptr inbounds [100 x i32], [100 x i32] addrspace(5)* %x, i32 0, i32 %i 40 store i32 7, i32 addrspace(5)* %arrayidx, align 4 41 %arrayidx2 = getelementptr inbounds [100 x i32], [100 x i32] addrspace(5)* %x, i32 0, i32 %j 42 %ld = load i32, i32 addrspace(5)* %arrayidx2, align 4 43 store i32 %ld, i32 addrspace(1)* %a, align 4 44 call void @llvm.lifetime.end.p5i8(i64 400, i8 addrspace(5)* nonnull %alloca.bc) #0 45 ret void 46} 47 48declare void @llvm.lifetime.start.p5i8(i64, i8 addrspace(5)* nocapture) #1 49 50declare void @llvm.lifetime.end.p5i8(i64, i8 addrspace(5)* nocapture) #1 51 52attributes #0 = { nounwind } 53attributes #1 = { argmemonly nounwind } 54