diff options
Diffstat (limited to 'llvm/test/CodeGen/WebAssembly/i32-load-store-alignment.ll')
-rw-r--r-- | llvm/test/CodeGen/WebAssembly/i32-load-store-alignment.ll | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/llvm/test/CodeGen/WebAssembly/i32-load-store-alignment.ll b/llvm/test/CodeGen/WebAssembly/i32-load-store-alignment.ll index 661d1b7bfc3..1296632cca3 100644 --- a/llvm/test/CodeGen/WebAssembly/i32-load-store-alignment.ll +++ b/llvm/test/CodeGen/WebAssembly/i32-load-store-alignment.ll @@ -1,4 +1,4 @@ -; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -disable-wasm-explicit-locals | FileCheck %s +; RUN: llc < %s -mattr=+atomics -asm-verbose=false -disable-wasm-fallthrough-return-opt -disable-wasm-explicit-locals | FileCheck %s ; Test loads and stores with custom alignment values. @@ -210,3 +210,29 @@ define void @sti16_a4(i16 *%p, i16 %v) { store i16 %v, i16* %p, align 4 ret void } + +; Atomics. +; Wasm atomics have the alignment field, but it must always have the +; type's natural alignment. + +; CHECK-LABEL: ldi32_atomic_a4: +; CHECK-NEXT: .param i32{{$}} +; CHECK-NEXT: .result i32{{$}} +; CHECK-NEXT: i32.atomic.load $push[[NUM:[0-9]+]]=, 0($0){{$}} +; CHECK-NEXT: return $pop[[NUM]]{{$}} +define i32 @ldi32_atomic_a4(i32 *%p) { + %v = load atomic i32, i32* %p seq_cst, align 4 + ret i32 %v +} + +; 8 is greater than the default alignment so it is rounded down to 4 + +; CHECK-LABEL: ldi32_atomic_a8: +; CHECK-NEXT: .param i32{{$}} +; CHECK-NEXT: .result i32{{$}} +; CHECK-NEXT: i32.atomic.load $push[[NUM:[0-9]+]]=, 0($0){{$}} +; CHECK-NEXT: return $pop[[NUM]]{{$}} +define i32 @ldi32_atomic_a8(i32 *%p) { + %v = load atomic i32, i32* %p seq_cst, align 8 + ret i32 %v +} |