Fuse address calculation into LOAD/STORE

This commit is contained in:
Dmitry Stogov 2022-08-24 16:11:04 +03:00
parent 70f6faa612
commit 65e1619de8
3 changed files with 32 additions and 24 deletions

View File

@ -1721,6 +1721,16 @@ store_int:
}
break;
case IR_LOAD:
if (ctx->use_lists[insn->op2].count == 1) {
ir_ref addr_ref = insn->op2;
if (!ctx->rules[addr_ref]) {
ctx->rules[addr_ref] = ir_match_insn(ctx, addr_ref, bb);
}
if (ctx->rules[addr_ref] == IR_LEA_OB) {
ctx->rules[addr_ref] = IR_SKIP_MEM;
}
}
if (IR_IS_TYPE_INT(insn->type)) {
return IR_LOAD_INT;
} else {
@ -1728,6 +1738,16 @@ store_int:
}
break;
case IR_STORE:
if (ctx->use_lists[insn->op2].count == 1) {
ir_ref addr_ref = insn->op2;
if (!ctx->rules[addr_ref]) {
ctx->rules[addr_ref] = ir_match_insn(ctx, addr_ref, bb);
}
if (ctx->rules[addr_ref] == IR_LEA_OB) {
ctx->rules[addr_ref] = IR_SKIP_MEM;
}
}
if (IR_IS_TYPE_INT(ctx->ir_base[insn->op3].type)) {
store_rule = IR_STORE_INT;
load_op = IR_LOAD;

View File

@ -45,18 +45,12 @@ test:
subq $0x10, %rsp
movq %rsp, %rdi
movb $0x68, (%rdi)
leaq 1(%rdi), %rax
movb $0x69, (%rax)
leaq 2(%rdi), %rax
movb $0x20, (%rax)
leaq 3(%rdi), %rax
movb $0x25, (%rax)
leaq 4(%rdi), %rax
movb $0x64, (%rax)
leaq 5(%rdi), %rax
movb $0xa, (%rax)
leaq 6(%rdi), %rax
movb $0, (%rax)
movb $0x69, 1(%rdi)
movb $0x20, 2(%rdi)
movb $0x25, 3(%rdi)
movb $0x64, 4(%rdi)
movb $0xa, 5(%rdi)
movb $0, 6(%rdi)
movl $0x2a, %esi
movabsq $_IO_printf, %rax
callq *%rax

View File

@ -43,18 +43,12 @@ test:
subq $8, %rsp
leaq (%rsp), %rdi
movb $0x68, (%rdi)
leaq 1(%rdi), %rax
movb $0x69, (%rax)
leaq 2(%rdi), %rax
movb $0x20, (%rax)
leaq 3(%rdi), %rax
movb $0x25, (%rax)
leaq 4(%rdi), %rax
movb $0x64, (%rax)
leaq 5(%rdi), %rax
movb $0xa, (%rax)
leaq 6(%rdi), %rax
movb $0, (%rax)
movb $0x69, 1(%rdi)
movb $0x20, 2(%rdi)
movb $0x25, 3(%rdi)
movb $0x64, 4(%rdi)
movb $0xa, 5(%rdi)
movb $0, 6(%rdi)
movl $0x2a, %esi
movabsq $_IO_printf, %rax
callq *%rax