optimize POPCNT implementation

This commit is contained in:
Stanislav Shwartsman 2012-09-21 14:56:56 +00:00
parent 74f5bb1934
commit eb348992c2
3 changed files with 6 additions and 6 deletions

View File

@ -347,8 +347,8 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::POPCNT_GwEwR(bxInstruction_c *i)
Bit16u op1_16 = 0;
while (op2_16 != 0) {
if (op2_16 & 1) op1_16++;
op2_16 >>= 1;
op2_16 &= (op2_16-1);
op1_16++;
}
Bit32u flags = op1_16 ? 0 : EFlagsZFMask;

View File

@ -352,8 +352,8 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::POPCNT_GdEdR(bxInstruction_c *i)
Bit32u op1_32 = 0;
while (op2_32 != 0) {
if (op2_32 & 1) op1_32++;
op2_32 >>= 1;
op2_32 &= (op2_32-1);
op1_32++;
}
Bit32u flags = op1_32 ? 0 : EFlagsZFMask;

View File

@ -356,8 +356,8 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::POPCNT_GqEqR(bxInstruction_c *i)
Bit64u op1_64 = 0;
while (op2_64 != 0) {
if (op2_64 & 1) op1_64++;
op2_64 >>= 1;
op2_64 &= (op2_64-1);
op1_64++;
}
Bit32u flags = op1_64 ? 0 : EFlagsZFMask;