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

clang pragma fp should allow emission of IR arcp flag #64798

Closed
arsenm opened this issue Aug 18, 2023 · 1 comment · Fixed by #68267
Closed

clang pragma fp should allow emission of IR arcp flag #64798

arsenm opened this issue Aug 18, 2023 · 1 comment · Fixed by #68267
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" enhancement Improving things as opposed to bug fixing, e.g. new or missing feature floating-point Floating-point math

Comments

@arsenm
Copy link
Contributor

arsenm commented Aug 18, 2023

pragma clang fp already exists which enables fast math flags within a scope. It currently supports pragma clang fp contract(value) and pragma clang fp reassociate(on).

I would like this extended to cover other fast math flags, in particular arcp. For something like

float fast_div(float x, float y) {
  #pragma clang fp reciprocal(on)
  return x / y;
}

I would hope to get

float @fast_div(float %, float %y) {
   %0 = fdiv arcp float %x, %y
   ret float %0 
}

@arsenm arsenm added enhancement Improving things as opposed to bug fixing, e.g. new or missing feature clang Clang issues not falling into any other category floating-point Floating-point math labels Aug 18, 2023
arsenm added a commit that referenced this issue Nov 28, 2023
Just follow along with the reassociate pragma. This allows locally
setting the arcp fast math flag. Previously you could only access this
through the global -freciprocal-math.

Fixes #64798
@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" and removed clang Clang issues not falling into any other category labels Nov 28, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Nov 28, 2023

@llvm/issue-subscribers-clang-frontend

Author: Matt Arsenault (arsenm)

pragma clang fp already exists which enables fast math flags within a scope. It currently supports `pragma clang fp contract(value)` and `pragma clang fp reassociate(on)`.

I would like this extended to cover other fast math flags, in particular arcp. For something like

float fast_div(float x, float y) {
  #pragma clang fp reciprocal(on)
  return x / y;
}

I would hope to get

float @<!-- -->fast_div(float %, float %y) {
   %0 = fdiv arcp float %x, %y
   ret float %0 
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" enhancement Improving things as opposed to bug fixing, e.g. new or missing feature floating-point Floating-point math
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants