File: promote-alloca-volatile.ll

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.6-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,304 kB
  • sloc: cpp: 7,438,677; ansic: 1,393,822; asm: 1,012,926; python: 241,650; f90: 86,635; objc: 75,479; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (56 lines) | stat: -rw-r--r-- 2,091 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
; RUN: opt -S -mtriple=amdgcn-unknown-amdhsa -passes=amdgpu-promote-alloca < %s | FileCheck %s

; CHECK-LABEL: @volatile_load(
; CHECK: alloca [4 x i32]
; CHECK: load volatile i32, ptr addrspace(5)
define amdgpu_kernel void @volatile_load(ptr addrspace(1) nocapture %out, ptr addrspace(1) nocapture %in) {
entry:
  %stack = alloca [4 x i32], align 4, addrspace(5)
  %tmp = load i32, ptr addrspace(1) %in, align 4
  %arrayidx1 = getelementptr inbounds [4 x i32], ptr addrspace(5) %stack, i32 0, i32 %tmp
  %load = load volatile i32, ptr addrspace(5) %arrayidx1
  store i32 %load, ptr addrspace(1) %out
 ret void
}

; CHECK-LABEL: @volatile_store(
; CHECK: alloca [4 x i32]
; CHECK: store volatile i32 %tmp, ptr addrspace(5)
define amdgpu_kernel void @volatile_store(ptr addrspace(1) nocapture %out, ptr addrspace(1) nocapture %in) {
entry:
  %stack = alloca [4 x i32], align 4, addrspace(5)
  %tmp = load i32, ptr addrspace(1) %in, align 4
  %arrayidx1 = getelementptr inbounds [4 x i32], ptr addrspace(5) %stack, i32 0, i32 %tmp
  store volatile i32 %tmp, ptr addrspace(5) %arrayidx1
 ret void
}

; CHECK-LABEL: @volatile_store_vec(
; CHECK: alloca [4 x i32]
; CHECK: store volatile <4 x i32>
define amdgpu_kernel void @volatile_store_vec(ptr addrspace(1) nocapture %out, ptr addrspace(1) nocapture %in) {
entry:
  %stack = alloca [4 x i32], align 4, addrspace(5)
  %tmp = load <4 x i32>, ptr addrspace(1) %in, align 16
  store volatile <4 x i32> %tmp, ptr addrspace(5) %stack
  ret void
}

; Has on OK non-volatile user but also a volatile user
; CHECK-LABEL: @volatile_and_non_volatile_load(
; CHECK: alloca double
; CHECK: load double
; CHECK: load volatile double
define amdgpu_kernel void @volatile_and_non_volatile_load(ptr addrspace(1) nocapture %arg, i32 %arg1) #0 {
bb:
  %tmp = alloca double, align 8, addrspace(5)
  store double 0.000000e+00, ptr addrspace(5) %tmp, align 8

  %tmp4 = load double, ptr addrspace(5) %tmp, align 8
  %tmp5 = load volatile double, ptr addrspace(5) %tmp, align 8

  store double %tmp4, ptr addrspace(1) %arg
  ret void
}

attributes #0 = { nounwind }