Skip to content

Commit 8be4511

Browse files
committed
C backend: less branching
1 parent 7bd3207 commit 8be4511

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

src/codegen/c.zig

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3348,8 +3348,8 @@ fn genBodyInner(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail,
33483348
.atomic_load => try airAtomicLoad(f, inst),
33493349
.memset => try airMemset(f, inst, false),
33503350
.memset_safe => try airMemset(f, inst, true),
3351-
.memcpy => try airMemcpy(f, inst),
3352-
.memmove => try airMemmove(f, inst),
3351+
.memcpy => try airMemcpy(f, inst, "memcpy("),
3352+
.memmove => try airMemcpy(f, inst, "memmove("),
33533353
.set_union_tag => try airSetUnionTag(f, inst),
33543354
.get_union_tag => try airGetUnionTag(f, inst),
33553355
.clz => try airUnBuiltinCall(f, inst, air_datas[@intFromEnum(inst)].ty_op.operand, "clz", .bits),
@@ -6976,15 +6976,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {
69766976
return .none;
69776977
}
69786978

6979-
fn airMemcpy(f: *Function, inst: Air.Inst.Index) !CValue {
6980-
return copyOp(f, inst, .memcpy);
6981-
}
6982-
6983-
fn airMemmove(f: *Function, inst: Air.Inst.Index) !CValue {
6984-
return copyOp(f, inst, .memmove);
6985-
}
6986-
6987-
fn copyOp(f: *Function, inst: Air.Inst.Index, op: enum { memcpy, memmove }) !CValue {
6979+
fn airMemcpy(f: *Function, inst: Air.Inst.Index, function_paren: []const u8) !CValue {
69886980
const pt = f.object.dg.pt;
69896981
const zcu = pt.zcu;
69906982
const bin_op = f.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
@@ -6999,10 +6991,6 @@ fn copyOp(f: *Function, inst: Air.Inst.Index, op: enum { memcpy, memmove }) !CVa
69996991
try writeArrayLen(f, writer, dest_ptr, dest_ty);
70006992
try writer.writeAll(" != 0) ");
70016993
}
7002-
const function_paren = switch (op) {
7003-
.memcpy => "memcpy(",
7004-
.memmove => "memmove(",
7005-
};
70066994
try writer.writeAll(function_paren);
70076995
try writeSliceOrPtr(f, writer, dest_ptr, dest_ty);
70086996
try writer.writeAll(", ");

0 commit comments

Comments
 (0)