bytecodealliance / bytecodealliance/wasmtime

Use stack args directly from stack, without load in entry block

Open
#6,301 1 comment 0 reactions 0 assignees View on GitHub
cranelift cranelift:goal:optimize-speed
Dominant language
Rust
Stars
18.6k
Forks
1.8k
Avg merge
1d 18h
Merged PRs (30d)
126

Description

I would not expect `movq 16(%rbp), %rax` to be lifted up into `block0`, as it is only used in `block1` and not `block2`. This results in a load that is not necessary for all possible executions.

```
test compile precise-output
target x86_64

function %foo(i32, i32, i32, i32, i32, i32, i32) -> i32 {
block0(v0: i32, v1: i32, v2: i32, v3: i32, v4: i32, v5: i32, v6: i32):
brif v0, block1, block2

block1:
return v5

block2:
return v6
}

; VCode:
; pushq %rbp
; movq %rsp, %rbp
; block0:
; movq %r9, %r11
; movq 16(%rbp), %rax
; testl %edi, %edi
; jnz label2; j label1
; block1:
; movq %rbp, %rsp
; popq %rbp
; ret
; block2:
; movq %r11, %rax
; movq %rbp, %rsp
; popq %rbp
; ret
;
; Disassembled:
; block0: ; offset 0x0
; pushq %rbp
; movq %rsp, %rbp
; block1: ; offset 0x4
; movq %r9, %r11
; movq 0x10(%rbp), %rax
; testl %edi, %edi
; jne 0x18
; block2: ; offset 0x13
; movq %rbp, %rsp
; popq %rbp
; retq
; block3: ; offset 0x18
; movq %r11, %rax
; movq %rbp, %rsp
; popq %rbp
; retq

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.