Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 62166ed

Browse files
committed
Correctly implement atomic_nand_* intrinsics
Fixes rust-lang#639
1 parent bc914cd commit 62166ed

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/intrinsics.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,12 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>(
810810
atomic_binop_return_old! (fx, band<T>(ptr, src) -> ret);
811811
};
812812
_ if intrinsic.starts_with("atomic_nand"), <T> (v ptr, v src) {
813-
atomic_binop_return_old! (fx, band_not<T>(ptr, src) -> ret);
813+
let clif_ty = fx.clif_type(T).unwrap();
814+
let old = fx.bcx.ins().load(clif_ty, MemFlags::new(), ptr, 0);
815+
let and = fx.bcx.ins().band(old, src);
816+
let new = fx.bcx.ins().bnot(and);
817+
fx.bcx.ins().store(MemFlags::new(), new, ptr, 0);
818+
ret.write_cvalue(fx, CValue::by_val(old, fx.layout_of(T)));
814819
};
815820
_ if intrinsic.starts_with("atomic_or"), <T> (v ptr, v src) {
816821
atomic_binop_return_old! (fx, bor<T>(ptr, src) -> ret);

0 commit comments

Comments
 (0)