Files
wasmtime/cranelift/filetests/licm/basic.cton
Denis Merigoux e47f4a49fb LICM pass (#87)
* LICM pass

* Uses loop analysis to detect loop tree
* For each loop (starting with the inner ones), create a pre-header and move there loop-invariant instructions
* An instruction is loop invariant if it does not use as argument a value defined earlier in the loop
* File tests to check LICM's correctness
* Optimized pre-header creation
If the loop already has a natural pre-header, we use it instead of creating a new one.
The natural pre-header of a loop is the only predecessor of the header it doesn't dominate.
2017-06-07 11:27:22 -07:00

32 lines
611 B
Plaintext

test licm
function simple_loop(i32) -> i32 {
ebb1(v0: i32):
v1 = iconst.i32 1
v2 = iconst.i32 2
v3 = iadd v1, v2
brz v0, ebb2(v0)
v4 = isub v0, v1
jump ebb1(v4)
ebb2(v5: i32):
return v5
}
; sameln: function simple_loop(i32) -> i32 {
; nextln: ebb2(v6: i32):
; nextln: v1 = iconst.i32 1
; nextln: v2 = iconst.i32 2
; nextln: v3 = iadd v1, v2
; nextln: jump ebb0(v6)
; nextln:
; nextln: ebb0(v0: i32):
; nextln: brz v0, ebb1(v0)
; nextln: v4 = isub v0, v1
; nextln: jump ebb0(v4)
; nextln:
; nextln: ebb1(v5: i32):
; nextln: return v5
; nextln: }