Commit a519c9dace

Jacob Young <jacobly0@users.noreply.github.com>
2023-04-21 06:15:19
cbe: fix atomic float min/max
These need `zig_atomic`, unlike int min/max.
1 parent e364627
Changed files (1)
src
codegen
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);