aboutsummaryrefslogtreecommitdiff
path: root/src/codegen
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2024-09-01 20:31:01 +0100
committermlugg <mlugg@mlugg.co.uk>2024-09-01 20:31:01 +0100
commit289c704b60c3e4b65bc00be55266b3f1c3fc27a3 (patch)
tree94c99c5a19ffe119259fdf89c9b454fb6c5b8a0f /src/codegen
parent0d295d76358037c15d9dc1f56b7b43de29a94d8d (diff)
downloadzig-289c704b60c3e4b65bc00be55266b3f1c3fc27a3.tar.gz
zig-289c704b60c3e4b65bc00be55266b3f1c3fc27a3.zip
cbe: don't emit 'x = x' in switch dispatch loop
Diffstat (limited to 'src/codegen')
-rw-r--r--src/codegen/c.zig7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig
index c761aa7225..0ec5513b6f 100644
--- a/src/codegen/c.zig
+++ b/src/codegen/c.zig
@@ -5065,11 +5065,8 @@ fn airSwitchBr(f: *Function, inst: Air.Inst.Index, is_dispatch_loop: bool) !void
// amount of C code we generate, which is probably more desirable here (and is simpler).
const condition = if (is_dispatch_loop) cond: {
const new_local = try f.allocLocal(inst, condition_ty);
- try f.writeCValue(writer, new_local, .Other);
- try writer.writeAll(" = ");
- try f.writeCValue(writer, init_condition, .Initializer);
- try writer.writeAll(";\n");
- try writer.print("zig_switch_{d}_loop:", .{@intFromEnum(inst)});
+ try f.copyCValue(try f.ctypeFromType(condition_ty, .complete), new_local, init_condition);
+ try writer.print("zig_switch_{d}_loop:\n", .{@intFromEnum(inst)});
try f.loop_switch_conds.put(gpa, inst, new_local.new_local);
break :cond new_local;
} else init_condition;