yuzu-emu
/
yuzu-mainline
Archived
1
0
Fork 0

Optimized Float<M,E> multiplication

Before:

ucomiss xmm1, xmm1
jp      .L9
pxor    xmm2, xmm2
mov     edx, 1
ucomiss xmm0, xmm2
setp    al
cmovne  eax, edx
test    al, al
jne     .L9
.L3:
movaps  xmm0, xmm2
ret
.L9:
ucomiss xmm0, xmm0
jp      .L10
pxor    xmm2, xmm2
mov     edx, 1
ucomiss xmm1, xmm2
setp    al
cmovne  eax, edx
test    al, al
je      .L3

After:

movaps  xmm2, xmm1
mulss   xmm2, xmm0
ucomiss xmm2, xmm2
jnp     .L3
ucomiss xmm1, xmm0
jnp     .L11
.L3:
movaps  xmm0, xmm2
ret
.L11:
pxor    xmm2, xmm2
jmp     .L3
This commit is contained in:
Huw Pascoe 2017-09-22 15:37:42 +01:00
parent 93930a966f
commit 903906da3b
1 changed files with 7 additions and 11 deletions

View File

@ -58,11 +58,12 @@ public:
} }
Float<M, E> operator*(const Float<M, E>& flt) const { Float<M, E> operator*(const Float<M, E>& flt) const {
if ((this->value == 0.f && !std::isnan(flt.value)) || float result = value * flt.ToFloat32();
(flt.value == 0.f && !std::isnan(this->value)))
// PICA gives 0 instead of NaN when multiplying by inf // PICA gives 0 instead of NaN when multiplying by inf
return Zero(); if (!std::isnan(value) && !std::isnan(flt.ToFloat32()))
return Float<M, E>::FromFloat32(ToFloat32() * flt.ToFloat32()); if (std::isnan(result))
result = 0.f;
return Float<M, E>::FromFloat32(result);
} }
Float<M, E> operator/(const Float<M, E>& flt) const { Float<M, E> operator/(const Float<M, E>& flt) const {
@ -78,12 +79,7 @@ public:
} }
Float<M, E>& operator*=(const Float<M, E>& flt) { Float<M, E>& operator*=(const Float<M, E>& flt) {
if ((this->value == 0.f && !std::isnan(flt.value)) || value = operator*(flt).value;
(flt.value == 0.f && !std::isnan(this->value)))
// PICA gives 0 instead of NaN when multiplying by inf
*this = Zero();
else
value *= flt.ToFloat32();
return *this; return *this;
} }