Correctly zero extend operand of fcvt_from_uint for 8ints and 16bit ints (#997)

Fixes #996
This commit is contained in:
bjorn3
2019-09-18 10:06:15 +02:00
committed by Benjamin Bouvier
parent 156938facf
commit add6a4f269
3 changed files with 26 additions and 19 deletions

View File

@@ -406,12 +406,16 @@ fn expand_fcvt_from_uint(
let mut pos = FuncCursor::new(func).at_inst(inst);
pos.use_srcloc(inst);
// Conversion from unsigned 32-bit is easy on x86-64.
// TODO: This should be guarded by an ISA check.
if xty == ir::types::I32 {
let wide = pos.ins().uextend(ir::types::I64, x);
pos.func.dfg.replace(inst).fcvt_from_sint(ty, wide);
return;
// Conversion from an unsigned int smaller than 64bit is easy on x86-64.
match xty {
ir::types::I8 | ir::types::I16 | ir::types::I32 => {
// TODO: This should be guarded by an ISA check.
let wide = pos.ins().uextend(ir::types::I64, x);
pos.func.dfg.replace(inst).fcvt_from_sint(ty, wide);
return;
}
ir::types::I64 => {}
_ => unimplemented!(),
}
let old_ebb = pos.func.layout.pp_ebb(inst);