Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 320dcaa

Browse filesBrowse files
committed
IR/Verifier: Allow vector type in atomic load and store
Vector types on atomics are assumed to be invalid by the verifier. However, this type can be valid if it is lowered by codegen. commit-id:72529270
1 parent b3963d3 commit 320dcaa
Copy full SHA for 320dcaa

File tree

5 files changed

+40
-17
lines changed
Filter options

5 files changed

+40
-17
lines changed

‎llvm/docs/LangRef.rst

Copy file name to clipboardExpand all lines: llvm/docs/LangRef.rst
+4-4
Original file line numberDiff line numberDiff line change
@@ -11206,8 +11206,8 @@ If the ``load`` is marked as ``atomic``, it takes an extra :ref:`ordering
1120611206
<ordering>` and optional ``syncscope("<target-scope>")`` argument. The
1120711207
``release`` and ``acq_rel`` orderings are not valid on ``load`` instructions.
1120811208
Atomic loads produce :ref:`defined <memmodel>` results when they may see
11209-
multiple atomic stores. The type of the pointee must be an integer, pointer, or
11210-
floating-point type whose bit width is a power of two greater than or equal to
11209+
multiple atomic stores. The type of the pointee must be an integer, pointer,
11210+
floating-point, or vector type whose bit width is a power of two greater than or equal to
1121111211
eight and less than or equal to a target-specific size limit. ``align`` must be
1121211212
explicitly specified on atomic loads. Note: if the alignment is not greater or
1121311213
equal to the size of the `<value>` type, the atomic operation is likely to
@@ -11347,8 +11347,8 @@ If the ``store`` is marked as ``atomic``, it takes an extra :ref:`ordering
1134711347
<ordering>` and optional ``syncscope("<target-scope>")`` argument. The
1134811348
``acquire`` and ``acq_rel`` orderings aren't valid on ``store`` instructions.
1134911349
Atomic loads produce :ref:`defined <memmodel>` results when they may see
11350-
multiple atomic stores. The type of the pointee must be an integer, pointer, or
11351-
floating-point type whose bit width is a power of two greater than or equal to
11350+
multiple atomic stores. The type of the pointee must be an integer, pointer,
11351+
floating-point, or vector type whose bit width is a power of two greater than or equal to
1135211352
eight and less than or equal to a target-specific size limit. ``align`` must be
1135311353
explicitly specified on atomic stores. Note: if the alignment is not greater or
1135411354
equal to the size of the `<value>` type, the atomic operation is likely to

‎llvm/docs/ReleaseNotes.md

Copy file name to clipboardExpand all lines: llvm/docs/ReleaseNotes.md
+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ Changes to the LLVM IR
6565
removed:
6666

6767
* `mul`
68+
* A `load atomic` may now be used with vector types.
6869

6970
* Updated semantics of `llvm.type.checked.load.relative` to match that of
7071
`llvm.load.relative`.

‎llvm/lib/IR/Verifier.cpp

Copy file name to clipboardExpand all lines: llvm/lib/IR/Verifier.cpp
+8-6
Original file line numberDiff line numberDiff line change
@@ -4304,9 +4304,10 @@ void Verifier::visitLoadInst(LoadInst &LI) {
43044304
Check(LI.getOrdering() != AtomicOrdering::Release &&
43054305
LI.getOrdering() != AtomicOrdering::AcquireRelease,
43064306
"Load cannot have Release ordering", &LI);
4307-
Check(ElTy->isIntOrPtrTy() || ElTy->isFloatingPointTy(),
4308-
"atomic load operand must have integer, pointer, or floating point "
4309-
"type!",
4307+
Check(ElTy->getScalarType()->isIntOrPtrTy() ||
4308+
ElTy->getScalarType()->isFloatingPointTy(),
4309+
"atomic load operand must have integer, pointer, floating point, "
4310+
"or vector type!",
43104311
ElTy, &LI);
43114312
checkAtomicMemAccessSize(ElTy, &LI);
43124313
} else {
@@ -4330,9 +4331,10 @@ void Verifier::visitStoreInst(StoreInst &SI) {
43304331
Check(SI.getOrdering() != AtomicOrdering::Acquire &&
43314332
SI.getOrdering() != AtomicOrdering::AcquireRelease,
43324333
"Store cannot have Acquire ordering", &SI);
4333-
Check(ElTy->isIntOrPtrTy() || ElTy->isFloatingPointTy(),
4334-
"atomic store operand must have integer, pointer, or floating point "
4335-
"type!",
4334+
Check(ElTy->getScalarType()->isIntOrPtrTy() ||
4335+
ElTy->getScalarType()->isFloatingPointTy(),
4336+
"atomic store operand must have integer, pointer, floating point, "
4337+
"or vector type!",
43364338
ElTy, &SI);
43374339
checkAtomicMemAccessSize(ElTy, &SI);
43384340
} else {

‎llvm/test/Assembler/atomic.ll

Copy file name to clipboardExpand all lines: llvm/test/Assembler/atomic.ll
+19
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,25 @@ define void @f(ptr %x) {
5252
; CHECK: atomicrmw volatile usub_sat ptr %x, i32 10 syncscope("agent") monotonic
5353
atomicrmw volatile usub_sat ptr %x, i32 10 syncscope("agent") monotonic
5454

55+
; CHECK : load atomic <1 x i32>, ptr %x unordered, align 4
56+
load atomic <1 x i32>, ptr %x unordered, align 4
57+
; CHECK : store atomic <1 x i32> splat (i32 3), ptr %x release, align 4
58+
store atomic <1 x i32> <i32 3>, ptr %x release, align 4
59+
; CHECK : load atomic <2 x i32>, ptr %x unordered, align 4
60+
load atomic <2 x i32>, ptr %x unordered, align 4
61+
; CHECK : store atomic <2 x i32> <i32 3, i32 4>, ptr %x release, align 4
62+
store atomic <2 x i32> <i32 3, i32 4>, ptr %x release, align 4
63+
64+
; CHECK : load atomic <2 x ptr>, ptr %x unordered, align 4
65+
load atomic <2 x ptr>, ptr %x unordered, align 4
66+
; CHECK : store atomic <2 x ptr> zeroinitializer, ptr %x release, align 4
67+
store atomic <2 x ptr> zeroinitializer, ptr %x release, align 4
68+
69+
; CHECK : load atomic <2 x float>, ptr %x unordered, align 4
70+
load atomic <2 x float>, ptr %x unordered, align 4
71+
; CHECK : store atomic <2 x float> <float 3.0, float 4.0>, ptr %x release, align 4
72+
store atomic <2 x float> <float 3.0, float 4.0>, ptr %x release, align 4
73+
5574
; CHECK: fence syncscope("singlethread") release
5675
fence syncscope("singlethread") release
5776
; CHECK: fence seq_cst

‎llvm/test/Verifier/atomics.ll

Copy file name to clipboard
+8-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
; RUN: not opt -passes=verify < %s 2>&1 | FileCheck %s
2+
; CHECK: atomic store operand must have integer, pointer, floating point, or vector type!
3+
; CHECK: atomic load operand must have integer, pointer, floating point, or vector type!
24

3-
; CHECK: atomic store operand must have integer, pointer, or floating point type!
4-
; CHECK: atomic load operand must have integer, pointer, or floating point type!
5+
%ty = type { i32 };
56

6-
define void @foo(ptr %P, <1 x i64> %v) {
7-
store atomic <1 x i64> %v, ptr %P unordered, align 8
7+
define void @foo(ptr %P, %ty %v) {
8+
store atomic %ty %v, ptr %P unordered, align 8
89
ret void
910
}
1011

11-
define <1 x i64> @bar(ptr %P) {
12-
%v = load atomic <1 x i64>, ptr %P unordered, align 8
13-
ret <1 x i64> %v
12+
define %ty @bar(ptr %P) {
13+
%v = load atomic %ty, ptr %P unordered, align 8
14+
ret %ty %v
1415
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.