From 6f7991f54adc5ecd4f4cd06e853ea87fcfc8efda Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 13 Oct 2023 21:32:35 -0400 Subject: [PATCH] Avoid loop. --- .../Implementation/PerformImplementation.hpp | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/InstructionSets/x86/Implementation/PerformImplementation.hpp b/InstructionSets/x86/Implementation/PerformImplementation.hpp index b6547de8d..dafe8b821 100644 --- a/InstructionSets/x86/Implementation/PerformImplementation.hpp +++ b/InstructionSets/x86/Implementation/PerformImplementation.hpp @@ -956,11 +956,23 @@ inline void rcl(IntT &destination, uint8_t count, Status &status) { */ auto temp_count = count % (Numeric::bit_size() + 1); auto carry = status.carry_bit(); - while(temp_count--) { - const IntT temp_carry = (destination >> (Numeric::bit_size() - 1)) & 1; - destination = (destination << 1) | carry; - carry = temp_carry; + switch(temp_count) { + case 0: break; + case Numeric::bit_size(): { + const IntT temp_carry = destination & 1; + destination = (destination >> 1) | (carry << (Numeric::bit_size() - 1)); + carry = temp_carry; + } break; + default: { + const IntT temp_carry = destination & (Numeric::top_bit() >> (temp_count - 1)); + destination = + (destination << temp_count) | + (destination >> (Numeric::bit_size() + 1 - temp_count)) | + (carry << (temp_count - 1)); + carry = temp_carry ? 1 : 0; + } break; } + status.set_from(carry); status.set_from( ((destination >> (Numeric::bit_size() - 1)) & 1) ^ carry