From 74e504330a75afe43117d8ef4ee350f9d6000c74 Mon Sep 17 00:00:00 2001 From: Philippe Sauter Date: Fri, 14 Jun 2024 13:01:18 +0200 Subject: [PATCH] peepopt: fix sign check in shiftadd --- passes/pmgen/peepopt_shiftadd.pmg | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/passes/pmgen/peepopt_shiftadd.pmg b/passes/pmgen/peepopt_shiftadd.pmg index 875559790..161effe43 100644 --- a/passes/pmgen/peepopt_shiftadd.pmg +++ b/passes/pmgen/peepopt_shiftadd.pmg @@ -63,7 +63,8 @@ match add define constport_signed param(add, !varport_A ? \A_SIGNED : \B_SIGNED).as_bool() define varport_signed param(add, varport_A ? \A_SIGNED : \B_SIGNED).as_bool(); - define offset_negative ((port(add, constport).bits().back() == State::S1) ^ (is_sub && varport_A)) + define const_negative (constport_signed && (port(add, constport).bits().back() == State::S1)) + define offset_negative ((is_sub && varport_A) ^ const_negative) // checking some value boundaries as well: // data[...-c +:W1] is fine for any signed var (pad at LSB, all data still accessible)