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 ; Has on OK non-volatile user but also a volatile user
29 ; CHECK-LABEL: @volatile_and_non_volatile_load(
30 ; CHECK: alloca double
32 ; CHECK: load volatile double
33 define amdgpu_kernel void @volatile_and_non_volatile_load(ptr addrspace(1) nocapture %arg, i32 %arg1) #0 {
35 %tmp = alloca double, align 8, addrspace(5)
36 store double 0.000000e+00, ptr addrspace(5) %tmp, align 8
38 %tmp4 = load double, ptr addrspace(5) %tmp, align 8
39 %tmp5 = load volatile double, ptr addrspace(5) %tmp, align 8
41 store double %tmp4, ptr addrspace(1) %arg
45 attributes #0 = { nounwind }