authorgravatar for joachim.schmidt557@outlook.comJoachim Schmidt <joachim.schmidt557@outlook.com> 2022-03-05 08:54:15+01:00
committergravatar for joachim.schmidt557@outlook.comJoachim Schmidt <joachim.schmidt557@outlook.com> 2022-03-05 08:56:01+01:00
loged7e2938ff2385d658f04248f1c757b324009be4
treeca45462b46d9babe9812e342ed941f16e9944e56
parent691ec964efd50307a498fa35b715b52da144b857
signaturelock-open Commit is signed but in an unrecognized format.

stage2 AArch64: generate less no-op branches

mirroring d486a7b81188ea1e027334c81589157efde2ad23 for aarch64

1 files changed, 22 insertions(+), 9 deletions(-)

src/arch/aarch64/CodeGen.zig+22-9
......@@ -443,14 +443,17 @@ fn gen(self: *Self) !void {
443443 });
444444
445445 // exitlude jumps
446 if (self.exitlude_jump_relocs.items.len == 1) {
447 // There is only one relocation. Hence,
448 // this relocation must be at the end of
449 // the code. Therefore, we can just delete
450 // the space initially reserved for the
451 // jump
452 self.mir_instructions.orderedRemove(self.exitlude_jump_relocs.items[0]);
453 } else for (self.exitlude_jump_relocs.items) |jmp_reloc| {
446 if (self.exitlude_jump_relocs.items.len > 0 and
447 self.exitlude_jump_relocs.items[self.exitlude_jump_relocs.items.len - 1] == self.mir_instructions.len - 2)
448 {
449 // If the last Mir instruction (apart from the
450 // dbg_epilogue_begin) is the last exitlude jump
451 // relocation (which would just jump one instruction
452 // further), it can be safely removed
453 self.mir_instructions.orderedRemove(self.exitlude_jump_relocs.pop());
454 }
455
456 for (self.exitlude_jump_relocs.items) |jmp_reloc| {
454457 self.mir_instructions.set(jmp_reloc, .{
455458 .tag = .b,
456459 .data = .{ .inst = @intCast(u32, self.mir_instructions.len) },
......@@ -2958,7 +2961,17 @@ fn airBlock(self: *Self, inst: Air.Inst.Index) !void {
29582961 const body = self.air.extra[extra.end..][0..extra.data.body_len];
29592962 try self.genBody(body);
29602963
2961 for (self.blocks.getPtr(inst).?.relocs.items) |reloc| try self.performReloc(reloc);
2964 // relocations for `br` instructions
2965 const relocs = &self.blocks.getPtr(inst).?.relocs;
2966 if (relocs.items.len > 0 and relocs.items[relocs.items.len - 1] == self.mir_instructions.len - 1) {
2967 // If the last Mir instruction is the last relocation (which
2968 // would just jump one instruction further), it can be safely
2969 // removed
2970 self.mir_instructions.orderedRemove(relocs.pop());
2971 }
2972 for (relocs.items) |reloc| {
2973 try self.performReloc(reloc);
2974 }
29622975
29632976 const result = self.blocks.getPtr(inst).?.mcv;
29642977 return self.finishAir(inst, result, .{ .none, .none, .none });