From c73925e775e7f611f0bdcb15dd687d1ef7a566a9 Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Thu, 26 Nov 2009 09:34:45 -0800 Subject: [PATCH] Handle word aligned bit moves more efficiently If the source and destination of a subvector to be moved in the vvp_vector4_t::mov method is nicely word aligned, and the transfer size is a full word, then we ar much better off handling that as a special case. This makes the move faster, and also avoids some shift overflow errors. --- vvp/vvp_net.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/vvp/vvp_net.cc b/vvp/vvp_net.cc index 075eafcbf..79734325b 100644 --- a/vvp/vvp_net.cc +++ b/vvp/vvp_net.cc @@ -1162,6 +1162,22 @@ void vvp_vector4_t::mov(unsigned dst, unsigned src, unsigned cnt) if ((doff+trans) > BITS_PER_WORD) trans = BITS_PER_WORD - doff; + if (trans == BITS_PER_WORD) { + // Special case: the transfer count is + // exactly an entire word. For this to be + // true, it must also be true that the + // pointers are aligned. The work is easy, + abits_ptr_[dptr] = abits_ptr_[sptr]; + bbits_ptr_[dptr] = bbits_ptr_[sptr]; + dptr += 1; + sptr += 1; + cnt -= BITS_PER_WORD; + continue; + } + + // Here we know that either the source or + // destination is unaligned, and also we know that + // the count is less then a full word. unsigned long vmask = (1UL << trans) - 1; unsigned long tmp;