Open llvmbot opened 7 years ago
-Ofast
enables -ffast-math
, which enables this libcall simplification as part of instcombine:
define linkonce_odr float @expf(float %_X) local_unnamed_addr #4 comdat {
entry:
%conv = fpext float %_X to double
%call = call fast double @exp(double %conv) #5
%conv1 = fptrunc double %call to float
ret float %conv1
}
->
define linkonce_odr float @expf(float %_X) local_unnamed_addr #4 comdat {
entry:
%expf = call fast float @expf(float %_X) #3
ret float %expf
}
And things go south from there, as we have infinite tail recursion. The solution is probably to say that expf
is not available on mingw targets (modify TargetLibraryInfo
), so we don't think we can materialize new calls to it.
Extended Description
When cross compiling for Windows (I haven't tested native compile on Windows),
std::exp()
is miscompiled as an infinite loop if-Ofast
is used.exp()
works correctly, andstd::exp()
works correctly on Linux.Clang version: 297935 (Also tried a 4.0.0 pre-release with similar results) OS: Arch Linux
Steps to reproduce: see
build.sh
in the tarballExpected result: No infinite loop should be produced. Actual result: The produced IR has a branch to a branch to itself (i.e: an infinite loop).
Contents of the tarball:
The remaining files are analogous for
-O3
and for native build.