[cfe-users] On the effect of #pragma STDC CX_LIMITED_RANGE ON

Christian Buchner via cfe-users cfe-users at lists.llvm.org
Thu Oct 15 02:29:55 PDT 2020


Hi.

I am finding that using said pragma does not have the intended effect of
disabling the C99 Annex G compliance that generates calls into the rather
slow __mulsc3 and __muldc3 soft float library functions. This behavior was
observed in Clang 11 and 10 (I did not test older revisions).

Allow me to link to godbolt to compare the generated code for this short
code snippet:

#pragma STDC CX_LIMITED_RANGE ON
#include <ccomplex>
std::complex<float> f(std::complex<float> x) {
  return x*x;
}

https://godbolt.org/z/cEs3E1

I find that the #pragma does not remove the call into __mulsc3 in said
example, whereas setting the flag -fno-honor-nans has the intended effect.

However I am worried that -fno-honor-nans would also affect code other than
complex number arithmetic.

Would you maybe consider supporting the -fcx-limited-range compiler switch
that is available in the GCC compiler?

Christian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20201015/3e289c8f/attachment.html>


More information about the cfe-users mailing list