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

Investigate the potential of adding specalisations for fixed points with zero-width fractions #92

Open
Pharap opened this issue Mar 26, 2021 · 0 comments
Assignees
Labels
Minor This change is a minor addition Optimisation This change somehow improves optimisation

Comments

@Pharap
Copy link
Owner

Pharap commented Mar 26, 2021

At present there's a strong possibility that the compiler does not optimise fixed points defined with a zero-width fraction part due to the extra operations required for fractional fixed points.

Although I think it's unlikely that anyone would actually want to use a fixed point with a zero-width fraction part (because this would be more or less equivalent to an integer of the same size), I think it would be good to specialise this case at some point on the off chance that there is a genuine need for such types given that there's a clear way to optimise in this situation.

In particular, some of the possible optimisations are:

  • getInteger() can avoid shifting by simply returning this->value.
  • getFraction() can avoid shifting by simply returning 0.
  • Multiplication and division do not need to upscale and downscale.
  • roundFixed() and similar functions could simply return their argument.
@Pharap Pharap added Minor This change is a minor addition Optimisation This change somehow improves optimisation labels Mar 26, 2021
@Pharap Pharap self-assigned this Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Minor This change is a minor addition Optimisation This change somehow improves optimisation
Projects
None yet
Development

No branches or pull requests

1 participant