bytecodealliance / bytecodealliance/wasmtime

[cranelift][x64][arm] Folding fneg + fabs

Open
#4,803 3 comments 0 reactions 0 assignees View on GitHub
cranelift cranelift:area:machinst cranelift:goal:optimize-speed enhancement performance
Dominant language
Rust
Stars
18.6k
Forks
1.8k
Avg merge
1d 18h
Merged PRs (30d)
126

Description

`fneg(fabs(x))` could be possible after `copysign(x, -C) -> fneg(fabs(x))` peephole optimization on LLVM / Binaryen, so I guess it's make sense to simplify it further on cranelift during lowering stage.

`x64`:
```asm
orsd xmm0, #0x8000000000000000
```
`ppc`:
```asm
fnabs 1,1
```
`s390x`:
```asm
lndbr %f0,%f0
```
the rest is preserving `fneg + fabs`

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.