1 ; RUN: opt -S -mtriple=amdgcn-unknown-amdhsa -amdgpu-promote-alloca < %s | FileCheck %s
3 ; CHECK-LABEL: @volatile_load(
4 ; CHECK: alloca [4 x i32]
5 ; CHECK: load volatile i32, i32*
6 define amdgpu_kernel void @volatile_load(i32 addrspace(1)* nocapture %out, i32 addrspace(1)* nocapture %in) {
8 %stack = alloca [4 x i32], align 4
9 %tmp = load i32, i32 addrspace(1)* %in, align 4
10 %arrayidx1 = getelementptr inbounds [4 x i32], [4 x i32]* %stack, i32 0, i32 %tmp
11 %load = load volatile i32, i32* %arrayidx1
12 store i32 %load, i32 addrspace(1)* %out
16 ; CHECK-LABEL: @volatile_store(
17 ; CHECK: alloca [4 x i32]
18 ; CHECK: store volatile i32 %tmp, i32*
19 define amdgpu_kernel void @volatile_store(i32 addrspace(1)* nocapture %out, i32 addrspace(1)* nocapture %in) {
21 %stack = alloca [4 x i32], align 4
22 %tmp = load i32, i32 addrspace(1)* %in, align 4
23 %arrayidx1 = getelementptr inbounds [4 x i32], [4 x i32]* %stack, i32 0, i32 %tmp
24 store volatile i32 %tmp, i32* %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(double addrspace(1)* nocapture %arg, i32 %arg1) #0 {
35 %tmp = alloca double, align 8
36 store double 0.000000e+00, double* %tmp, align 8
38 %tmp4 = load double, double* %tmp, align 8
39 %tmp5 = load volatile double, double* %tmp, align 8
41 store double %tmp4, double addrspace(1)* %arg
45 attributes #0 = { nounwind }