Don't allow loop preheaders to have critical edges.
If the block which would be a preheader for a loop has other successors, don't hoist instructions into it. Instead create a dedicated preheader.
This commit is contained in:
committed by
Benjamin Bouvier
parent
641771ac6a
commit
0fed78e063
42
cranelift/filetests/licm/critical-edge.clif
Normal file
42
cranelift/filetests/licm/critical-edge.clif
Normal file
@@ -0,0 +1,42 @@
|
||||
test licm
|
||||
target riscv32
|
||||
|
||||
; The loop in this function is entered from a critical edge.
|
||||
|
||||
function %critical_edge(i32, i32) -> i32 {
|
||||
|
||||
ebb0(v0: i32, v7: i32):
|
||||
[SBzero#38] brnz v7, ebb1(v0)
|
||||
[Iret#19] return v0
|
||||
|
||||
ebb1(v1: i32):
|
||||
v2 = iconst.i32 1
|
||||
v3 = iconst.i32 2
|
||||
v4 = iadd v2, v3
|
||||
[SBzero#18] brz v1, ebb2(v1)
|
||||
v5 = isub v1, v2
|
||||
[UJ#1b] jump ebb1(v5)
|
||||
|
||||
ebb2(v6: i32):
|
||||
[Iret#19] return v6
|
||||
|
||||
}
|
||||
; sameln: function %critical_edge
|
||||
; nextln: ebb0(v0: i32, v7: i32):
|
||||
; nextln: brnz v7, ebb3(v0)
|
||||
; nextln: return v0
|
||||
; nextln:
|
||||
; nextln: ebb3(v8: i32):
|
||||
; nextln: v2 = iconst.i32 1
|
||||
; nextln: v3 = iconst.i32 2
|
||||
; nextln: v4 = iadd v2, v3
|
||||
; nextln: jump ebb1(v8)
|
||||
; nextln:
|
||||
; nextln: ebb1(v1: i32):
|
||||
; nextln: brz v1, ebb2(v1)
|
||||
; nextln: v5 = isub v1, v2
|
||||
; nextln: jump ebb1(v5)
|
||||
; nextln:
|
||||
; nextln: ebb2(v6: i32):
|
||||
; nextln: return v6
|
||||
; nextln: }
|
||||
Reference in New Issue
Block a user