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 LLVM: Improve approximate FCEQ/FCMEQ #8729

Merged
merged 1 commit into from
Aug 22, 2021
Merged

Conversation

Whatcookie
Copy link
Member

@Whatcookie Whatcookie commented Aug 14, 2020

Accurately emulate SPU floating compare equals by using integer comparisons when the floating value will be interpreted as NAN by x86 hardware.

@Whatcookie Whatcookie marked this pull request as draft August 14, 2020 01:43
@elad335
Copy link
Contributor

elad335 commented Oct 28, 2020

any update?

@Xcedf
Copy link

Xcedf commented Aug 17, 2021

Fixes bottom-right quarter of godrays in TLoU
Before:
non-PR
After:
PR

@Linear524
Copy link

Kick this to master branch please...

@AniLeo
Copy link
Member

AniLeo commented Aug 18, 2021

Pending a change + rebase that Whatcookie will push

@Whatcookie Whatcookie marked this pull request as ready for review August 20, 2021 05:20
@Whatcookie
Copy link
Member Author

Rebased and added a simple optimization for comparisons against safe constants.

@AniLeo AniLeo requested a review from Nekotekina August 20, 2021 05:23
}
}

if (safe_float_compare.any())
Copy link
Contributor

@elad335 elad335 Aug 20, 2021

Choose a reason for hiding this comment

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

Int comparison is preferred over float.

Copy link
Member Author

Choose a reason for hiding this comment

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

There may be extra latency when switching between floating point and integer execution domains. It may be faster regardless on intel where floating comparisons are 4 cycle latency and int comparisons are 1 cycle, but on zen they're both 1 cycle so I think it's ideal to use the float comparison first since future intel cpus may also have fast floating comparisons like zen.

Copy link
Member

Choose a reason for hiding this comment

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

Should be fine either way, it barely matters in practice.

- It's 100% accurate, but will sit under approx xfloat anyways
- Attempts to use a single instruction when 1 value is constant
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants