From a519c9daced7dc182a57d8a49992463eabf3c825 Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Fri, 21 Apr 2023 00:15:19 -0400 Subject: [PATCH] cbe: fix atomic float min/max These need `zig_atomic`, unlike int min/max. --- src/codegen/c.zig | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/codegen/c.zig b/src/codegen/c.zig index 58b9de0cd0..832a97526e 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -6070,17 +6070,15 @@ fn airAtomicRmw(f: *Function, inst: Air.Inst.Index) !CValue { try writer.writeByte('('); try f.writeCValue(writer, local, .Other); try writer.writeAll(", ("); - switch (extra.op()) { - else => { - try writer.writeAll("zig_atomic("); - try f.renderType(writer, ty); - try writer.writeByte(')'); - }, - .Nand, .Min, .Max => { - // These are missing from stdatomic.h, so no atomic types for now. - try f.renderType(writer, ty); - }, - } + const use_atomic = switch (extra.op()) { + else => true, + // These are missing from stdatomic.h, so no atomic types for now. + .Nand => false, + .Min, .Max => is_float, + }; + if (use_atomic) try writer.writeAll("zig_atomic("); + try f.renderType(writer, ty); + if (use_atomic) try writer.writeByte(')'); if (ptr_ty.isVolatilePtr()) try writer.writeAll(" volatile"); try writer.writeAll(" *)"); try f.writeCValue(writer, ptr, .Other);