aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/block.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/block.rs b/src/block.rs
index bde60fc..0e64bbe 100644
--- a/src/block.rs
+++ b/src/block.rs
@@ -148,6 +148,14 @@ impl BitXor<Block> for Block {
impl Shl<u32> for Block {
type Output = Block;
fn shl(self, rhs: u32) -> Block {
+ // We often use a shift by one, for example in the multiplication. We therefore optimize
+ // for this special case.
+ #[cfg(feature = "simd")]
+ {
+ if rhs == 1 {
+ return Block((self.0 << 1) | (self.0.shift_elements_left::<1>(0) >> 7));
+ }
+ }
Block::from(self.to_int() << rhs)
}
}