Fold 'ifcmp_imm' + 'brif' where imm is zero and cond is 'eq' or 'ne', into 'brz' or 'brnz'.

This commit is contained in:
Tyler McMullen
2018-12-18 12:10:00 -08:00
committed by Benjamin Bouvier
parent 9b156fd9bb
commit fc6876c68e
2 changed files with 115 additions and 1 deletions

View File

@@ -0,0 +1,29 @@
test simple_preopt
target x86_64
function %brif_to_brz_fold(i32) -> i32 {
ebb0(v0: i32):
v1 = ifcmp_imm v0, 0
brif eq v1, ebb1
jump ebb2
ebb1:
v2 = iconst.i32 1
return v2
ebb2:
v3 = iconst.i32 2
return v3
}
; sameln: function %brif_to_brz_fold
; nextln: ebb0(v0: i32):
; nextln: v1 = ifcmp_imm v0, 0
; nextln: brz v0, ebb1
; nextln: jump ebb2
; nextln:
; nextln: ebb1:
; nextln: v2 = iconst.i32 1
; nextln: return v2
; nextln:
; nextln: ebb2:
; nextln: v3 = iconst.i32 2
; nextln: return v3
; nextln: }