Allow load fuson for CALL and TAILCALL with arguments

This commit is contained in:
Dmitry Stogov 2023-02-14 14:51:12 +03:00
parent 36553fdf14
commit 1d7ab16c2a
3 changed files with 6 additions and 10 deletions

View File

@ -1370,8 +1370,7 @@ binop_fp:
ctx->flags |= IR_HAS_CALLS;
IR_FALLTHROUGH;
case IR_TAILCALL:
if (ir_input_edges_count(ctx, insn) == 2 /* no arguments */
&& insn->op2 > bb->start
if (insn->op2 > bb->start
&& insn->op2 < ref
&& !ctx->rules[insn->op2]) {
ir_match_fuse_load(ctx, insn->op2, bb);

View File

@ -24,7 +24,6 @@ test:
movl %ebx, 0x18(%esp)
movl 0x20(%esp), %ebx
movl 0x30(%esp), %eax
movl (%eax), %eax
leal .L1, %ecx
movl %ecx, (%esp)
movl 0x28(%esp), %ecx
@ -33,12 +32,12 @@ test:
movl %ecx, 8(%esp)
movl 0x24(%esp), %ecx
movl %ecx, 0xc(%esp)
calll *%eax
calll *(%eax)
leal (%eax, %ebx), %eax
movl 0x18(%esp), %ebx
addl $0x1c, %esp
retl
.rodata
.db 0x90
.db 0x90, 0x90, 0x90
.L1:
.db 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x25, 0x64, 0x21, 0x0a, 0x00

View File

@ -23,18 +23,16 @@ test:
subq $8, %rsp
movq %rbx, (%rsp)
movl %edi, %ebx
movq (%r8), %rax
movl %ecx, %r8d
movl %ecx, %eax
movl %esi, %ecx
movl %edx, %esi
movl %r8d, %edx
movl %eax, %edx
leaq .L1(%rip), %rdi
callq *%rax
callq *(%r8)
leal (%rax, %rbx), %eax
movq (%rsp), %rbx
addq $8, %rsp
retq
.rodata
.db 0x90, 0x90, 0x90, 0x90
.L1:
.db 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x25, 0x64, 0x21, 0x0a, 0x00