Files
wasmtime/filetests/licm/nested_loops.cton
Denis Merigoux 9b06f76057 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

53 lines
1.1 KiB
Plaintext

test licm
function nested_loops(i32) -> i32 {
ebb0(v0: i32):
v1 = iconst.i32 1
v2 = iconst.i32 2
v3 = iadd v1, v2
v4 = isub v0, v1
jump ebb1(v4,v4)
ebb1(v10: i32,v11: i32):
brz v11, ebb2(v10)
v12 = iconst.i32 1
v15 = iadd v12, v4
v13 = isub v11, v12
jump ebb1(v10,v13)
ebb2(v20: i32):
brz v20, ebb3(v20)
jump ebb0(v20)
ebb3(v30: i32):
return v30
}
; sameln:function nested_loops(i32) -> i32 {
; nextln: ebb4(v12: i32):
; nextln: v1 = iconst.i32 1
; nextln: v2 = iconst.i32 2
; nextln: v3 = iadd v1, v2
; nextln: v7 = iconst.i32 1
; nextln: jump ebb0(v12)
; nextln:
; nextln: ebb0(v0: i32):
; nextln: v4 = isub v0, v1
; nextln: v8 = iadd.i32 v7, v4
; nextln: jump ebb1(v4, v4)
; nextln:
; nextln: ebb1(v5: i32, v6: i32):
; nextln: brz v6, ebb2(v5)
; nextln: v9 = isub v6, v7
; nextln: jump ebb1(v5, v9)
; nextln:
; nextln: ebb2(v10: i32):
; nextln: brz v10, ebb3(v10)
; nextln: jump ebb0(v10)
; nextln:
; nextln: ebb3(v11: i32):
; nextln: return v11
; nextln: }