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

[FEATURE REQUEST] Allow disabling constant folding that replaces division by multiplication #210

Open
divVerent opened this issue Nov 3, 2024 · 0 comments

Comments

@divVerent
Copy link
Contributor

Replacing a / b by a * (1 / b), which gmqcc sometimes does, can cause an accuracy loss.

See explanations on gcc's -freciprocal-math and why it's not default but only part of -funsafe-math-optimizations.

Attached an incomplete patch to do this. It lacks the case for vector / float division - that "folding" actually emulates the missing DIV_VF QC instruction, and as such, a different emulation has to be provided when the folding is to be turned off.

As such, with the optimization flag, v / f should be implemented like now as v * (1 / f), whereas without the flag, it should be implemented as vec3(v_x / f, v_y / f, v_z / f), which admittedly incurs an insane amount of QC instructions.

move-reciprocal-division-to-non-default-flag.diff.txt

nyov pushed a commit to xonotic/xonotic-data.pk3dir that referenced this issue Jan 23, 2025
It's a bit less accurate than it should be in GMQCC:

graphitemaster/gmqcc#210

To get better equality between compilers, change the code so both
compilers emit the same.
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

No branches or pull requests

1 participant