Remove unwrap() for branch folding
This commit is contained in:
committed by
Dan Gohman
parent
4ee2747c5b
commit
d8d573208b
@@ -52,3 +52,28 @@ ebb2:
|
|||||||
; nextln: v2 = iconst.i32 24
|
; nextln: v2 = iconst.i32 24
|
||||||
; nextln: return v2
|
; nextln: return v2
|
||||||
; nextln: }
|
; nextln: }
|
||||||
|
|
||||||
|
function %brz_fold_param(b1) -> i32 {
|
||||||
|
ebb0(v0: b1):
|
||||||
|
brz v0, ebb2
|
||||||
|
jump ebb1
|
||||||
|
ebb1:
|
||||||
|
v1 = iconst.i32 42
|
||||||
|
return v1
|
||||||
|
ebb2:
|
||||||
|
v2 = iconst.i32 24
|
||||||
|
return v2
|
||||||
|
}
|
||||||
|
; sameln: function %brz_fold_param(b1) -> i32 fast {
|
||||||
|
; nextln: ebb0(v0: b1):
|
||||||
|
; nextln: brz v0, ebb2
|
||||||
|
; nextln: jump ebb1
|
||||||
|
; nextln:
|
||||||
|
; nextln: ebb1:
|
||||||
|
; nextln: v1 = iconst.i32 42
|
||||||
|
; nextln: return v1
|
||||||
|
; nextln:
|
||||||
|
; nextln: ebb2:
|
||||||
|
; nextln: v2 = iconst.i32 24
|
||||||
|
; nextln: return v2
|
||||||
|
; nextln: }
|
||||||
|
|||||||
@@ -232,7 +232,10 @@ fn fold_branch(pos: &mut FuncCursor, inst: ir::Inst, opcode: ir::Opcode) {
|
|||||||
let values = pos.func.dfg.inst_args(inst);
|
let values = pos.func.dfg.inst_args(inst);
|
||||||
let inst_data = &pos.func.dfg[inst];
|
let inst_data = &pos.func.dfg[inst];
|
||||||
(
|
(
|
||||||
resolve_value_to_imm(&pos.func.dfg, values[0]).unwrap(),
|
match resolve_value_to_imm(&pos.func.dfg, values[0]) {
|
||||||
|
Some(imm) => imm,
|
||||||
|
None => return,
|
||||||
|
},
|
||||||
inst_data.branch_destination().unwrap(),
|
inst_data.branch_destination().unwrap(),
|
||||||
values[1..].to_vec(),
|
values[1..].to_vec(),
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user