Skip to content

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

Description

@divVerent

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions