From bb5cf570e5ac2227c09a01af8acd56e55f00438a Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 10 Apr 2022 15:18:23 -0400 Subject: [PATCH] Remove conditional, make generic enough for both 32- and 64-bit operation. --- InstructionSets/PowerPC/Instruction.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/InstructionSets/PowerPC/Instruction.hpp b/InstructionSets/PowerPC/Instruction.hpp index 1c95cd3d4..07d9b0175 100644 --- a/InstructionSets/PowerPC/Instruction.hpp +++ b/InstructionSets/PowerPC/Instruction.hpp @@ -1451,12 +1451,13 @@ struct Instruction { /// mb < me+1 => set [mb, me] /// mb == me+1 => set all bits /// mb > me+1 => complement of set [me+1, mb-1] - uint32_t rotate_mask() const { + template IntT rotate_mask() const { const auto mb_bit = mb(); const auto me_bit = me(); - uint32_t result = (0xffff'ffff >> mb_bit) ^ (0x7fff'ffff >> me_bit); - return result ^ ((mb_bit < me_bit+1) ? 0 : 0xffff'ffff); + const IntT result = (0xffff'ffff >> mb_bit) ^ (0x7fff'ffff >> me_bit); + const IntT sign = ~IntT((int32_t(mb_bit) - int32_t(me_bit+1)) >> 16); + return result ^ sign; } /// Condition register source bit A.