fixing negation truncation

This commit is contained in:
Jakub Doka 2024-11-11 23:02:02 +01:00
parent f5f9060803
commit ce2f7d2059
No known key found for this signature in database
GPG key ID: C6E9A89936B8C143

View file

@ -566,7 +566,12 @@ impl TokenKind {
fn unop(&self, dst: ty::Id, src: ty::Id) -> Option<fn(u8, u8) -> EncodedInstr> {
let src_idx = src.simple_size().unwrap().ilog2() as usize - 2;
Some(match self {
Self::Sub => instrs::neg,
Self::Sub => [
|a, b| sub8(a, 0, b),
|a, b| sub16(a, 0, b),
|a, b| sub32(a, 0, b),
|a, b| sub64(a, 0, b),
][src.simple_size().unwrap().ilog2() as usize],
Self::Not => instrs::not,
Self::Float if dst.is_float() && src.is_integer() => {
debug_assert_matches!(