Don't try to fold an atomic load into other instructions. Atomic loads may require different instructions / barriers / etc. Wasm started using this functionality in https://github.com/llvm/llvm-project/pull/182767. It's not really specific to wasm, but the problem is masked on some other targets (e.g. on X86 even a seq_cst atomic load can be lowered to a plain load).
28 lines
1 KiB
LLVM
28 lines
1 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
|
|
; RUN: llc -mtriple=wasm32 -mattr=+atomics -wasm-disable-explicit-locals -wasm-keep-registers -fast-isel -O0 < %s | FileCheck %s
|
|
|
|
define i64 @sext_atomic_i8(ptr %p) {
|
|
; CHECK-LABEL: sext_atomic_i8:
|
|
; CHECK: .functype sext_atomic_i8 (i32) -> (i64)
|
|
; CHECK-NEXT: # %bb.0:
|
|
; CHECK-NEXT: i32.atomic.load8_u $push0=, 0($0)
|
|
; CHECK-NEXT: i64.extend_i32_u $push1=, $pop0
|
|
; CHECK-NEXT: i64.extend8_s $push2=, $pop1
|
|
; CHECK-NEXT: return $pop2
|
|
%v = load atomic i8, ptr %p seq_cst, align 1
|
|
%s = sext i8 %v to i64
|
|
ret i64 %s
|
|
}
|
|
|
|
define i32 @zext_atomic_i8(ptr %p) {
|
|
; CHECK-LABEL: zext_atomic_i8:
|
|
; CHECK: .functype zext_atomic_i8 (i32) -> (i32)
|
|
; CHECK-NEXT: # %bb.0:
|
|
; CHECK-NEXT: i32.atomic.load8_u $push0=, 0($0)
|
|
; CHECK-NEXT: i32.const $push1=, 255
|
|
; CHECK-NEXT: i32.and $push2=, $pop0, $pop1
|
|
; CHECK-NEXT: return $pop2
|
|
%v = load atomic i8, ptr %p seq_cst, align 1
|
|
%z = zext i8 %v to i32
|
|
ret i32 %z
|
|
}
|