From 68a9aa7c29b72543552af9795310cc598a7975d6 Mon Sep 17 00:00:00 2001 From: Philippe Sauter Date: Fri, 26 Jan 2024 11:44:44 +0100 Subject: [PATCH] peepopt: handle offset too large in `shiftadd` If the offset is larger than the signal itself, meaning the signal is completely shifted out, it tried to extract a negative amount of bits from the old signal. This RTL pattern is suspicious since it is a complicated way of arriving at a constant value, so we warn the user. --- passes/pmgen/peepopt_shiftadd.pmg | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/passes/pmgen/peepopt_shiftadd.pmg b/passes/pmgen/peepopt_shiftadd.pmg index f9c930eae3d..6f2dd89af55 100644 --- a/passes/pmgen/peepopt_shiftadd.pmg +++ b/passes/pmgen/peepopt_shiftadd.pmg @@ -103,8 +103,18 @@ code new_a.append(old_a); } else { // data >> (...+c) transformed to data[MAX:c] >> (...) - new_a.append(old_a.extract_end(offset)); - + if(offset < GetSize(old_a)) // some signal bits left? + new_a.append(old_a.extract_end(offset)); + else { + if(shift->type.in($shiftx)) + log_warning("at %s: result of indexed part-selection is always constant (selecting from '%s' with index '%s + %d')\n", \ + shift->get_src_attribute().c_str(), log_signal(old_a), log_signal(var_signal), offset); + else + log_warning("at %s: result of shift operation is always constant (shifting '%s' by '%s + %d'-bits)\n", \ + shift->get_src_attribute().c_str(), log_signal(old_a), log_signal(var_signal), offset); + } + + // is it fine to leave new_a empty? (size 0) } SigSpec new_b = {var_signal, SigSpec(State::S0, log2scale)};