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 <bool> constport_signed param(add, !varport_A ? \A_SIGNED : \B_SIGNED).as_bool() define <bool> varport_signed param(add, varport_A ? \A_SIGNED : \B_SIGNED).as_bool(); - define <bool> offset_negative ((port(add, constport).bits().back() == State::S1) ^ (is_sub && varport_A)) + define <bool> const_negative (constport_signed && (port(add, constport).bits().back() == State::S1)) + define <bool> 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)