From bfac81c807d44c82f84751139b51af8a0d646f8d Mon Sep 17 00:00:00 2001 From: Jakub Doka Date: Mon, 16 Dec 2024 10:35:11 +0100 Subject: [PATCH] fixing a bug with ITF selecting based of input instead of output type Signed-off-by: Jakub Doka --- lang/src/backend/hbvm.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lang/src/backend/hbvm.rs b/lang/src/backend/hbvm.rs index 61982d6bf..27734b495 100644 --- a/lang/src/backend/hbvm.rs +++ b/lang/src/backend/hbvm.rs @@ -414,11 +414,9 @@ impl Nodes { && op.cond_op(self[o].ty).is_none()) }), Kind::BinOp { op: TokenKind::Mul } if node.ty.is_float() => { - false - && node.outputs.iter().all(|&n| { - self[n].kind == Kind::BinOp { op: TokenKind::Add } - && self[n].inputs[1] == nid - }) + node.outputs.iter().all(|&n| { + self[n].kind == Kind::BinOp { op: TokenKind::Add } && self[n].inputs[1] == nid + }) } Kind::BinOp { op: TokenKind::Add | TokenKind::Sub } => { (self.is_locked(node.inputs[1]) && !self[node.inputs[1]].ty.is_float()) @@ -624,7 +622,7 @@ impl TokenKind { (dst.simple_size(), src.simple_size()), (Some(4 | 8), Some(8)) ); - [instrs::itf32, instrs::itf64][src_idx - 2] + [instrs::itf32, instrs::itf64][dst.simple_size().unwrap().ilog2() as usize - 2] } Self::Number if src.is_float() && dst.is_integer() => { [|a, b| instrs::fti32(a, b, 1), |a, b| instrs::fti64(a, b, 1)][src_idx - 2]