Files
wasmtime/cranelift/codegen/src/opts
Alex Crichton 7ebff82861 Optimize sign extension via shifts (#6220)
* Optimize sign extension via shifts

This commit adds egraph optimization patterns for left-shifting a value
and then right-shifting it as a form of sign extending its lower bits.
This matches the behavior of the WebAssembly `i32.extend8_s`
instruction, for example. Note that the lowering of that WebAssembly
instruction does not use shifts, but historical versions of LLVM that
didn't support the instruction, or versions with the instruction
disabled, will use shifts instead.

A second rule for reduction-of-extend being the same as the original
value was added to keep an existing shift-related test passing as well.

* Add reference assemblies for new opts
2023-04-17 18:48:08 +00:00
..

Rules here are allowed to rewrite pure expressions arbitrarily, using the same inputs as the original, or fewer. In other words, we cannot pull a new eclass id out of thin air and refer to it, other than a piece of the input or a new node that we construct; but we can freely rewrite e.g. x+y-y to x.