From 62166ed9c8cd1b495bddc3fcfb02f48d3fa0e043 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 1 Aug 2019 10:58:18 +0200 Subject: [PATCH] Correctly implement atomic_nand_* intrinsics Fixes #639 --- src/intrinsics.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 7da7e738f52..8fee0fa457d 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -810,7 +810,12 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( atomic_binop_return_old! (fx, band(ptr, src) -> ret); }; _ if intrinsic.starts_with("atomic_nand"), (v ptr, v src) { - atomic_binop_return_old! (fx, band_not(ptr, src) -> ret); + let clif_ty = fx.clif_type(T).unwrap(); + let old = fx.bcx.ins().load(clif_ty, MemFlags::new(), ptr, 0); + let and = fx.bcx.ins().band(old, src); + let new = fx.bcx.ins().bnot(and); + fx.bcx.ins().store(MemFlags::new(), new, ptr, 0); + ret.write_cvalue(fx, CValue::by_val(old, fx.layout_of(T))); }; _ if intrinsic.starts_with("atomic_or"), (v ptr, v src) { atomic_binop_return_old! (fx, bor(ptr, src) -> ret);