[PATCH] D114564: Fix the use of -fno-approx-func along with -Ofast or -ffast-math

Masoud Ataei via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 25 09:29:52 PST 2021


masoud.ataei marked 2 inline comments as done.
masoud.ataei added inline comments.


================
Comment at: clang/lib/Driver/ToolChains/Clang.cpp:2760
     case options::OPT_fno_honor_nans:       HonorNaNs = false;        break;
     case options::OPT_fapprox_func:         ApproxFunc = true;        break;
     case options::OPT_fno_approx_func:      ApproxFunc = false;       break;
----------------
andrew.w.kaylor wrote:
> Should this also imply "MathErrno = false"?
I don't think setting ApproxFunc to true should imply "MathErrno = false". 

Let say someone have a math library that compute approximate result for none special input/output but returns NaN, INF and errno correctly otherwise. That is actually can be fairly common, because performance in the none special cases are much more important that the special ones. So returning errno in the special outputs theoretically should not effect the performance on the main path. Therefore, I think compiler should not assume anything about MathErrno value based on ApproxFunc value.


================
Comment at: clang/lib/Driver/ToolChains/Clang.cpp:2762
     case options::OPT_fno_approx_func:      ApproxFunc = false;       break;
     case options::OPT_fmath_errno:          MathErrno = true;         break;
     case options::OPT_fno_math_errno:       MathErrno = false;        break;
----------------
andrew.w.kaylor wrote:
> Should this conflict with -fapprox-func?
Same as above.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114564/new/

https://reviews.llvm.org/D114564



More information about the cfe-commits mailing list