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

When -ffast-math was specified on Clang command line, it seems to be impossible to later turn off FP contraction via pragmas #54925

Open
rygorous opened this issue Apr 15, 2022 · 4 comments
Labels
clang:codegen clang:frontend Language frontend issues, e.g. anything involving "Sema"

Comments

@rygorous
Copy link

Example C code:

float g(float a, float b, float c) {
    return a * b + c;
}
#pragma float_control(precise, on)
#pragma STDC FP_CONTRACT OFF

float f(float a, float b, float c) {
    return a * b + c;
}

Compile for x86-64 with -mfma -O2 -ffast-math. Expectation is that g may use FMAs but f may not, but in fact both produce FMAs in Clang-14.0.0. Compiler Explorer link with repro: https://godbolt.org/z/TacbzWzxn

It works when there is no -ffast-math on the command line. Presumably the presence of that flag on the command line triggers some global override behavior?

I would love to just remove fast-math from the command line for the relevant TU, but this turns out to be problematic in the build setup for the project I need this in. I was asked to use pragmas for my use case instead, but can't properly because of the above problem.

@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" and removed new issue labels Apr 15, 2022
@llvmbot
Copy link
Collaborator

llvmbot commented Apr 15, 2022

@llvm/issue-subscribers-clang-frontend

@fhahn
Copy link
Contributor

fhahn commented Apr 15, 2022

@zahiraam I think you have been working in this area. Do you have any ideas what could be going wrong?

@fhahn
Copy link
Contributor

fhahn commented Aug 22, 2022

Still an issue.

@llvmbot
Copy link
Collaborator

llvmbot commented Aug 22, 2022

@llvm/issue-subscribers-clang-codegen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:codegen clang:frontend Language frontend issues, e.g. anything involving "Sema"
Projects
None yet
Development

No branches or pull requests

4 participants