You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cranelift: Rewrite conditional branches to unconditional traps into conditional traps during legalization (#10988)
* Cranelift: Legalize via a backwards walk, rather than forwards
Note: the test expectation change in `filetests/egraph/misc.clif` is simply
because we happen to change the order in which we created the legalized
`stack_addr` instructions that get GVN'd together, and therefore also changed
their relative value numbering. We dedupe to the value that occurs first in the
function, which is the one inserted into the DFG *after* the other now because
of the backwards traversal, and it therefore has a different value number from
before. The resulting program is identical, modulo value numbering.
* Cranelift: Rewrite conditional branches to unconditional traps into conditional traps during legalization
Given this instruction:
```clif
brif v0, block1, block2
```
If we know that `block1` does nothing but immediately trap then we can rewrite
that `brif` into the following:
```clif
trapz v0, <trapcode>
jump block2
```
(And we can do the equivalent with `trapz` if `block2` immediately traps).
This transformation allows for the conditional trap instructions to be GVN'd and
for our egraphs mid-end to generally better optimize the program. We
additionally have better codegen in our backends for `trapz` than branches to
unconditional traps.
Fixes#10941
* Update CLIF filetests and Wasmtime disas tests
0 commit comments