From eafb4dc6496e8265e69d9f3d9854b83891c48287 Mon Sep 17 00:00:00 2001 From: Chris Fallin Date: Tue, 29 Nov 2022 19:54:35 -0800 Subject: [PATCH] Bugfix: i64.eqz returns i32, not i64, in constprop pass. --- src/passes/basic_opt.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/passes/basic_opt.rs b/src/passes/basic_opt.rs index fae48c7..cced07b 100644 --- a/src/passes/basic_opt.rs +++ b/src/passes/basic_opt.rs @@ -83,44 +83,44 @@ fn const_eval(op: &Operator, vals: &[ConstVal]) -> Option { (Operator::I32GeU, [ConstVal::I32(a), ConstVal::I32(b)]) => { Some(ConstVal::I32(if a >= b { 1 } else { 0 })) } - (Operator::I64Eqz, [ConstVal::I64(a)]) => Some(ConstVal::I64(if *a == 0 { 1 } else { 0 })), + (Operator::I64Eqz, [ConstVal::I64(a)]) => Some(ConstVal::I32(if *a == 0 { 1 } else { 0 })), (Operator::I64Eq, [ConstVal::I64(a), ConstVal::I64(b)]) => { - Some(ConstVal::I64(if a == b { 1 } else { 0 })) + Some(ConstVal::I32(if a == b { 1 } else { 0 })) } (Operator::I64Ne, [ConstVal::I64(a), ConstVal::I64(b)]) => { - Some(ConstVal::I64(if a != b { 1 } else { 0 })) + Some(ConstVal::I32(if a != b { 1 } else { 0 })) } (Operator::I64LtS, [ConstVal::I64(a), ConstVal::I64(b)]) => { - Some(ConstVal::I64(if (*a as i64) < (*b as i64) { 1 } else { 0 })) + Some(ConstVal::I32(if (*a as i64) < (*b as i64) { 1 } else { 0 })) } (Operator::I64LtU, [ConstVal::I64(a), ConstVal::I64(b)]) => { - Some(ConstVal::I64(if a < b { 1 } else { 0 })) + Some(ConstVal::I32(if a < b { 1 } else { 0 })) } (Operator::I64GtS, [ConstVal::I64(a), ConstVal::I64(b)]) => { - Some(ConstVal::I64(if (*a as i64) > (*b as i64) { 1 } else { 0 })) + Some(ConstVal::I32(if (*a as i64) > (*b as i64) { 1 } else { 0 })) } (Operator::I64GtU, [ConstVal::I64(a), ConstVal::I64(b)]) => { - Some(ConstVal::I64(if a > b { 1 } else { 0 })) + Some(ConstVal::I32(if a > b { 1 } else { 0 })) } (Operator::I64LeS, [ConstVal::I64(a), ConstVal::I64(b)]) => { - Some(ConstVal::I64(if (*a as i64) <= (*b as i64) { + Some(ConstVal::I32(if (*a as i64) <= (*b as i64) { 1 } else { 0 })) } (Operator::I64LeU, [ConstVal::I64(a), ConstVal::I64(b)]) => { - Some(ConstVal::I64(if a <= b { 1 } else { 0 })) + Some(ConstVal::I32(if a <= b { 1 } else { 0 })) } (Operator::I64GeS, [ConstVal::I64(a), ConstVal::I64(b)]) => { - Some(ConstVal::I64(if (*a as i64) >= (*b as i64) { + Some(ConstVal::I32(if (*a as i64) >= (*b as i64) { 1 } else { 0 })) } (Operator::I64GeU, [ConstVal::I64(a), ConstVal::I64(b)]) => { - Some(ConstVal::I64(if a >= b { 1 } else { 0 })) + Some(ConstVal::I32(if a >= b { 1 } else { 0 })) } (Operator::I32Add, [ConstVal::I32(a), ConstVal::I32(b)]) => {