From 6cf02ed94f46d32e6116ba834894f4022fb0d407 Mon Sep 17 00:00:00 2001 From: whitequark Date: Sat, 13 Jun 2020 00:49:44 +0000 Subject: [PATCH] cxxrtl: fix rzext(). This was a correctness issue, but one of the consequences is that it resulted in jumps in generated machine code where there should have been none. As a side effect of fixing the bug, Minerva SoC became 10% faster. --- backends/cxxrtl/cxxrtl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backends/cxxrtl/cxxrtl.h b/backends/cxxrtl/cxxrtl.h index ce21cc1e6..10184bb3f 100644 --- a/backends/cxxrtl/cxxrtl.h +++ b/backends/cxxrtl/cxxrtl.h @@ -165,8 +165,8 @@ struct value : public expr_base> { carry = (shift_bits == 0) ? 0 : data[n] >> (chunk::bits - shift_bits); } - if (carry != 0) - result.data[result.chunks - 1] = carry; + if (shift_chunks + chunks < result.chunks) + result.data[shift_chunks + chunks] = carry; return result; }