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

Consider -fno-math-errno #18156

Closed
4 of 6 tasks
fp64 opened this issue Sep 16, 2023 · 1 comment · Fixed by #18158
Closed
4 of 6 tasks

Consider -fno-math-errno #18156

fp64 opened this issue Sep 16, 2023 · 1 comment · Fixed by #18158
Milestone

Comments

@fp64
Copy link
Contributor

fp64 commented Sep 16, 2023

Platform

Linux / BSD

Compiler and build tool versions

GCC 10.2.1

Operating system version

GNU/Linux

Build commands used

./b.sh

What happens

Unlike the value-changing optimizations (-ffast-math), the -fno-math-errno is widely considered a good idea (see e.g. here for a nice write-up).
The C++ Standard doesn't even guarantee math functions set errno in the first place, and, as far as I can tell, PPSSPP does not check the math errno in any way (I'm surprised errno is used as much as it is, in other places).
The most obvious difference is that sqrtf compiles to sqrtss xmm0, xmm0 rather than

        pxor    xmm1, xmm1
        ucomiss xmm1, xmm0
        ja      .L10
        sqrtss  xmm0, xmm0
        ret
.L10:
        jmp     sqrtf

but some other functions are also affected (lrintf, etc.). The example is x86, but ARM is similar.

Unfortunately, there does not seem to be a similar option for MSVC.

Adding -fno-math-errno to CMakeLists.txt did not cause any obvious problems, and seems to improve performance a bit, when tested in Ridge Racer on SoftGPU on my system (or it might have been noise).

Planning to add it, if there are no objections.

Note: it apparently also messes with errno of malloc, which should not be problematic.

PPSSPP version affected

v1.16-4-gd4365c6ae

Last working version

No response

Checklist

  • Test in the latest git build in case it's already fixed.
  • Make sure to run git submodule update --init --recursive before building.
  • Search for other reports of the same issue.
  • Try deleting the build directory and running the build again.
  • Check GitHub Actions, which builds every merge and PR.
  • Include logs and help us reproduce.
@unknownbrackets
Copy link
Collaborator

Yeah, I don't really see a downside. In theory, we might someday want to more accurately (read: at all) update the fcr31 exception bits, but I don't think I've ever seen a game read them. Doesn't mean it can't happen, though...

-[Unknown]

fp64 added a commit to fp64/ppsspp that referenced this issue Sep 16, 2023
@hrydgard hrydgard added this to the v1.16.2 milestone Sep 16, 2023
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 a pull request may close this issue.

3 participants