Revert "Added optimizations to ClassifyFloat/Double functions in Mathutil.cpp and to PPCCache.cpp"

This reverts commit 7aae9ccbc0.

Reasons:
- no test results have been provided to prove the usefulness of the patch
- broken coding style
- the author hasn't replied to any criticism
This commit is contained in:
NeoBrainX 2013-06-22 12:22:16 +02:00
parent 266236d6a4
commit 15943de313
2 changed files with 73 additions and 64 deletions

View File

@ -13,54 +13,61 @@ namespace MathUtil
{ {
u32 ClassifyDouble(double dvalue) u32 ClassifyDouble(double dvalue)
{ {
// TODO: Optimize the below to be as fast as possible. // TODO: Optimize the below to be as fast as possible.
u64 exp = *(u64*)(&dvalue) & DOUBLE_EXP; IntDouble value;
if (exp != DOUBLE_ZERO && exp != DOUBLE_EXP) value.d = dvalue;
{ u64 sign = value.i & DOUBLE_SIGN;
// Nice normalized number. u64 exp = value.i & DOUBLE_EXP;
return *(u64*)(&dvalue)&DOUBLE_SIGN ? PPC_FPCLASS_NN : PPC_FPCLASS_PN; if (exp > DOUBLE_ZERO && exp < DOUBLE_EXP)
} {
else // Nice normalized number.
{ return sign ? PPC_FPCLASS_NN : PPC_FPCLASS_PN;
if (*(u64*)(&dvalue) & DOUBLE_FRAC) }
{ else
if (exp) {
{ u64 mantissa = value.i & DOUBLE_FRAC;
return PPC_FPCLASS_QNAN; if (mantissa)
} {
else if (exp)
{ {
// Denormalized number. return PPC_FPCLASS_QNAN;
return *(u64*)(&dvalue)&DOUBLE_SIGN ? PPC_FPCLASS_ND : PPC_FPCLASS_PD; }
} else
} {
else if (exp) // Denormalized number.
{ return sign ? PPC_FPCLASS_ND : PPC_FPCLASS_PD;
//Infinite }
return *(u64*)(&dvalue)&DOUBLE_SIGN ? PPC_FPCLASS_NINF : PPC_FPCLASS_PINF; }
} else if (exp)
else {
{ //Infinite
//Zero return sign ? PPC_FPCLASS_NINF : PPC_FPCLASS_PINF;
return *(u64*)(&dvalue)&DOUBLE_SIGN ? PPC_FPCLASS_NZ : PPC_FPCLASS_PZ; }
} else
} {
} //Zero
return sign ? PPC_FPCLASS_NZ : PPC_FPCLASS_PZ;
}
}
}
u32 ClassifyFloat(float fvalue) u32 ClassifyFloat(float fvalue)
{ {
// TODO: Optimize the below to be as fast as possible. // TODO: Optimize the below to be as fast as possible.
u32 exp = *(u32*)(&fvalue) & FLOAT_EXP; IntFloat value;
value.f = fvalue;
u32 sign = value.i & FLOAT_SIGN;
u32 exp = value.i & FLOAT_EXP;
if (exp > FLOAT_ZERO && exp < FLOAT_EXP) if (exp > FLOAT_ZERO && exp < FLOAT_EXP)
{ {
// Nice normalized number. // Nice normalized number.
return *(u32*)(&fvalue) & FLOAT_SIGN ? PPC_FPCLASS_NN : PPC_FPCLASS_PN; return sign ? PPC_FPCLASS_NN : PPC_FPCLASS_PN;
} }
else else
{ {
if (*(u32*)(&fvalue) & FLOAT_FRAC) u32 mantissa = value.i & FLOAT_FRAC;
if (mantissa)
{ {
if (exp) if (exp)
{ {
@ -69,18 +76,18 @@ u32 ClassifyFloat(float fvalue)
else else
{ {
// Denormalized number. // Denormalized number.
return *(u32*)(&fvalue) & FLOAT_SIGN ? PPC_FPCLASS_ND : PPC_FPCLASS_PD; return sign ? PPC_FPCLASS_ND : PPC_FPCLASS_PD;
} }
} }
else if (exp) else if (exp)
{ {
// Infinite // Infinite
return *(u32*)(&fvalue) & FLOAT_SIGN ? PPC_FPCLASS_NINF : PPC_FPCLASS_PINF; return sign ? PPC_FPCLASS_NINF : PPC_FPCLASS_PINF;
} }
else else
{ {
//Zero //Zero
return *(u32*)(&fvalue) & FLOAT_SIGN ? PPC_FPCLASS_NZ : PPC_FPCLASS_PZ; return sign ? PPC_FPCLASS_NZ : PPC_FPCLASS_PZ;
} }
} }
} }

View File

@ -26,29 +26,31 @@ namespace PowerPC
for (u32 m = 0; m < 128; m++) for (u32 m = 0; m < 128; m++)
{ {
u32 w; u32 b[7];
if(m & (1<<0)) for (int i = 0; i < 7; i++) b[i] = m & (1<<i);
if(m & (1<<2)) u32 w;
if(m & (1<<6)) if (b[0])
w=7; if (b[2])
else if (b[6])
w=6; w = 7;
else else
if(m & (1<<5)) w = 6;
w=5; else
else if (b[5])
w=4; w = 5;
else else
if(m & (1<<1)) w = 4;
if(m & (1<<4)) else
w=3; if (b[1])
else if (b[4])
w=2; w = 3;
else else
if(m & (1<<3)) w = 2;
w=1; else
else if (b[3])
w=0; w = 1;
else
w = 0;
way_from_plru[m] = w; way_from_plru[m] = w;
} }
} }