Skip to content

Commit

Permalink
peepopt: fix sign check in shiftadd
Browse files Browse the repository at this point in the history
  • Loading branch information
phsauter committed Jun 14, 2024
1 parent 34b5c6d commit 74e5043
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion passes/pmgen/peepopt_shiftadd.pmg
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 74e5043

Please sign in to comment.