Bugfix: i64.eqz returns i32, not i64, in constprop pass.

This commit is contained in:
Chris Fallin 2022-11-29 19:54:35 -08:00
parent 8caba239fa
commit eafb4dc649
No known key found for this signature in database
GPG key ID: 31649E4FE65EB465

View file

@ -83,44 +83,44 @@ fn const_eval(op: &Operator, vals: &[ConstVal]) -> Option<ConstVal> {
(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)]) => {