File: atomicrmw-expand.ll

package info (click to toggle)
llvm-toolchain-21 1%3A21.1.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 2,245,044 kB
  • sloc: cpp: 7,619,726; ansic: 1,434,018; asm: 1,058,748; python: 252,740; f90: 94,671; objc: 70,685; lisp: 42,813; pascal: 18,401; sh: 8,601; ml: 5,111; perl: 4,720; makefile: 3,666; awk: 3,523; javascript: 2,409; xml: 892; fortran: 770
file content (141 lines) | stat: -rw-r--r-- 4,076 bytes parent folder | download | duplicates (2)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
; RUN: llc < %s -mtriple=nvptx64 -mcpu=sm_30 | FileCheck %s --check-prefixes=ALL,SM30
; RUN: llc < %s -mtriple=nvptx64 -mcpu=sm_60 | FileCheck %s --check-prefixes=ALL,SM60
; RUN: %if ptxas %{ llc < %s -mtriple=nvptx64 -mcpu=sm_30 | %ptxas-verify %}
; RUN: %if ptxas %{ llc < %s -mtriple=nvptx64 -mcpu=sm_60 | %ptxas-verify -arch=sm_60 %}

; CHECK-LABEL: fadd_double
define void @fadd_double(ptr %0, double %1) {
entry:
  ; SM30: atom.cas.b64
  ; SM60: atom.add.f64
  %2 = atomicrmw fadd ptr %0, double %1 monotonic, align 8
  ret void
}

; CHECK-LABEL: fadd_float
define void @fadd_float(ptr %0, float %1) {
entry:
  ; ALL: atom.add.f32
  %2 = atomicrmw fadd ptr %0, float %1 monotonic, align 4
  ret void
}

; CHECK-LABEL: bitwise_i32
define void @bitwise_i32(ptr %0, i32 %1) {
entry:
  ; ALL: atom.and.b32
  %2 = atomicrmw and ptr %0, i32 %1 monotonic, align 4
  ; ALL: atom.or.b32
  %3 = atomicrmw or ptr %0, i32 %1 monotonic, align 4
  ; ALL: atom.xor.b32
  %4 = atomicrmw xor ptr %0, i32 %1 monotonic, align 4
  ; ALL: atom.exch.b32
  %5 = atomicrmw xchg ptr %0, i32 %1 monotonic, align 4
  ret void
}

; CHECK-LABEL: bitwise_i64
define void @bitwise_i64(ptr %0, i64 %1) {
entry:
  ; SM30: atom.cas.b64
  ; SM60: atom.and.b64
  %2 = atomicrmw and ptr %0, i64 %1 monotonic, align 8
  ; SM30: atom.cas.b64
  ; SM60: atom.or.b64
  %3 = atomicrmw or ptr %0, i64 %1 monotonic, align 8
  ; SM30: atom.cas.b64
  ; SM60: atom.xor.b64
  %4 = atomicrmw xor ptr %0, i64 %1 monotonic, align 8
  ; SM30: atom.cas.b64
  ; SM60: atom.exch.b64
  %5 = atomicrmw xchg ptr %0, i64 %1 monotonic, align 8
  ret void
}

; CHECK-LABEL: minmax_i32
define void @minmax_i32(ptr %0, i32 %1) {
entry:
  ; ALL: atom.min.s32
  %2 = atomicrmw min ptr %0, i32 %1 monotonic, align 4
  ; ALL: atom.max.s32
  %3 = atomicrmw max ptr %0, i32 %1 monotonic, align 4
  ; ALL: atom.min.u32
  %4 = atomicrmw umin ptr %0, i32 %1 monotonic, align 4
  ; ALL: atom.max.u32
  %5 = atomicrmw umax ptr %0, i32 %1 monotonic, align 4
  ret void
}

; CHECK-LABEL: minmax_i64
define void @minmax_i64(ptr %0, i64 %1) {
entry:
  ; SM30: atom.cas.b64
  ; SM60: atom.min.s64
  %2 = atomicrmw min ptr %0, i64 %1 monotonic, align 8
  ; SM30: atom.cas.b64
  ; SM60: atom.max.s64
  %3 = atomicrmw max ptr %0, i64 %1 monotonic, align 8
  ; SM30: atom.cas.b64
  ; SM60: atom.min.u64
  %4 = atomicrmw umin ptr %0, i64 %1 monotonic, align 8
  ; SM30: atom.cas.b64
  ; SM60: atom.max.u64
  %5 = atomicrmw umax ptr %0, i64 %1 monotonic, align 8
  ret void
}

; CHECK-LABEL: bitwise_i8
define void @bitwise_i8(ptr %0, i8 %1) {
entry:
  ; ALL: atom.and.b32
  %2 = atomicrmw and ptr %0, i8 %1 monotonic, align 1
  ; ALL: atom.or.b32
  %3 = atomicrmw or ptr %0, i8 %1 monotonic, align 1
  ; ALL: atom.xor.b32
  %4 = atomicrmw xor ptr %0, i8 %1 monotonic, align 1
  ; ALL: atom.cas.b32
  %5 = atomicrmw xchg ptr %0, i8 %1 monotonic, align 1
  ret void
}

; CHECK-LABEL: minmax_i8
define void @minmax_i8(ptr %0, i8 %1) {
entry:
  ; ALL: atom.cas.b32
  %2 = atomicrmw min ptr %0, i8 %1 monotonic, align 1
  ; ALL: atom.cas.b32
  %3 = atomicrmw max ptr %0, i8 %1 monotonic, align 1
  ; ALL: atom.cas.b32
  %4 = atomicrmw umin ptr %0, i8 %1 monotonic, align 1
  ; ALL: atom.cas.b32
  %5 = atomicrmw umax ptr %0, i8 %1 monotonic, align 1
  ret void
}

; CHECK-LABEL: bitwise_i16
define void @bitwise_i16(ptr %0, i16 %1) {
entry:
  ; ALL: atom.and.b32
  %2 = atomicrmw and ptr %0, i16 %1 monotonic, align 2
  ; ALL: atom.or.b32
  %3 = atomicrmw or ptr %0, i16 %1 monotonic, align 2
  ; ALL: atom.xor.b32
  %4 = atomicrmw xor ptr %0, i16 %1 monotonic, align 2
  ; ALL: atom.cas.b32
  %5 = atomicrmw xchg ptr %0, i16 %1 monotonic, align 2
  ret void
}

; CHECK-LABEL: minmax_i16
define void @minmax_i16(ptr %0, i16 %1) {
entry:
  ; ALL: atom.cas.b32
  %2 = atomicrmw min ptr %0, i16 %1 monotonic, align 2
  ; ALL: atom.cas.b32
  %3 = atomicrmw max ptr %0, i16 %1 monotonic, align 2
  ; ALL: atom.cas.b32
  %4 = atomicrmw umin ptr %0, i16 %1 monotonic, align 2
  ; ALL: atom.cas.b32
  %5 = atomicrmw umax ptr %0, i16 %1 monotonic, align 2
  ret void
}