Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPU Precise interpreter: More efficient float exceptions detection #4155

Merged
merged 1 commit into from
Feb 28, 2018
Merged

SPU Precise interpreter: More efficient float exceptions detection #4155

merged 1 commit into from
Feb 28, 2018

Conversation

elad335
Copy link
Contributor

@elad335 elad335 commented Feb 7, 2018

  • Optimize floating point exception checking :
    read once the MXCSR register and use his value to check for all exceptions.

  • Optimize setting the floating point's rounding mode with constant values ( also the first commit ) ,cause the compiler won't do it on his own ,as tested in godbolt .

@TheCake21
Copy link

GCC is clearly optimizing setting the floating point rounding mode as soon as you actually tun on compiler optimization. https://godbolt.org/g/j1f1GH

@AniLeo
Copy link
Member

AniLeo commented Feb 8, 2018

Just a reminder that our appimages are built with Clang 5.0

@@ -1899,18 +1899,19 @@ static void DFASM(SPUThread& spu, spu_opcode_t op, DoubleOp operation)
case DFASM_S: result = a - b; break;
case DFASM_M: result = a * b; break;
}
if (fetestexcept(FE_INVALID))
const u32 e = fetestexcept(FE_ALL_EXCEPT);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e?

Copy link
Contributor Author

@elad335 elad335 Feb 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a shortcut for exceptions

@@ -1262,34 +1262,32 @@ bool SPUThread::set_ch_value(u32 ch, u32 value)
if (code < 64)
{
/* ===== sys_spu_thread_send_event (used by spu_printf) ===== */

u32 spup = code & 63;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No useless changes, please.

@TheCake21
Copy link

@elad335 I don't see where your problem is. The call to fesetround is clearly inlined. The copy of set_rounding is created because that function might be exported. It won't happen if you declare it static which is the case in SPUInterpreter. See https://godbolt.org/g/kyFsfP

{
spu.fpscr.setDoublePrecisionExceptionFlags(i, FPSCR_DINV);
result = DOUBLE_NAN;
}
else
{
if (fetestexcept(FE_OVERFLOW))
if (e & FE_OVERFLOW)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_mm_getcsr is not compatible with these constants.
There are _MM_MASK_OVERFLOW and similar ones.

read once the MXCSR register and use his value to check for all exceptions
@Nekotekina Nekotekina merged commit 6e8ccbc into RPCS3:master Feb 28, 2018
@elad335 elad335 deleted the smol branch February 28, 2018 17:31
@elad335 elad335 changed the title [spu] random optimizations SPU Precise interpreter: More efficient float exceptions detection Oct 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants