1 ; RUN: opt -S -mtriple=amdgcn-unknown-amdhsa -passes=amdgpu-promote-alloca < %s | FileCheck %s
3 ; CHECK-LABEL: @volatile_load(
4 ; CHECK: alloca [4 x i32]
5 ; CHECK: load volatile i32, ptr addrspace(5)
6 define amdgpu_kernel void @volatile_load(ptr addrspace(1) nocapture %out, ptr addrspace(1) nocapture %in) {
8 %stack = alloca [4 x i32], align 4, addrspace(5)
9 %tmp = load i32, ptr addrspace(1) %in, align 4
10 %arrayidx1 = getelementptr inbounds [4 x i32], ptr addrspace(5) %stack, i32 0, i32 %tmp
11 %load = load volatile i32, ptr addrspace(5) %arrayidx1
12 store i32 %load, ptr addrspace(1) %out
16 ; CHECK-LABEL: @volatile_store(
17 ; CHECK: alloca [4 x i32]
18 ; CHECK: store volatile i32 %tmp, ptr addrspace(5)
19 define amdgpu_kernel void @volatile_store(ptr addrspace(1) nocapture %out, ptr addrspace(1) nocapture %in) {
21 %stack = alloca [4 x i32], align 4, addrspace(5)
22 %tmp = load i32, ptr addrspace(1) %in, align 4
23 %arrayidx1 = getelementptr inbounds [4 x i32], ptr addrspace(5) %stack, i32 0, i32 %tmp
24 store volatile i32 %tmp, ptr addrspace(5) %arrayidx1
28 ; CHECK-LABEL: @volatile_store_vec(
29 ; CHECK: alloca [4 x i32]
30 ; CHECK: store volatile <4 x i32>
31 define amdgpu_kernel void @volatile_store_vec(ptr addrspace(1) nocapture %out, ptr addrspace(1) nocapture %in) {
33 %stack = alloca [4 x i32], align 4, addrspace(5)
34 %tmp = load <4 x i32>, ptr addrspace(1) %in, align 16
35 store volatile <4 x i32> %tmp, ptr addrspace(5) %stack
39 ; Has on OK non-volatile user but also a volatile user
40 ; CHECK-LABEL: @volatile_and_non_volatile_load(
41 ; CHECK: alloca double
43 ; CHECK: load volatile double
44 define amdgpu_kernel void @volatile_and_non_volatile_load(ptr addrspace(1) nocapture %arg, i32 %arg1) #0 {
46 %tmp = alloca double, align 8, addrspace(5)
47 store double 0.000000e+00, ptr addrspace(5) %tmp, align 8
49 %tmp4 = load double, ptr addrspace(5) %tmp, align 8
50 %tmp5 = load volatile double, ptr addrspace(5) %tmp, align 8
52 store double %tmp4, ptr addrspace(1) %arg
56 attributes #0 = { nounwind }