[PATCH] D31806: [SimplifyLibCalls] Fix infinite loop with fast-math optimization.
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 10 11:53:18 PDT 2017
efriedma added a comment.
gcc transforms the given C code to a call to expf(), just like LLVM, but then it looks like their inliner works a bit differently so the generated code ends up with a call to expf() rather than an infinite loop. With your patch, LLVM also generates a call to expf(). This seems weird... does MinGW's C library actually have an expf() function?
================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:935
+ // same name and signature as the float version of this call!
+ // e.g. float floorf(float val) { return (float) floor((double) val); }
+ if (!Callee->isIntrinsic()) {
----------------
You might want to explicitly note that MinGW is doing this; otherwise it seems like a weird hack, because it makes no sense to write an inline function like this if you have a standard-compliant C library.
================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:945
+ if (FT->getReturnType()->isFloatTy() && (FT->getNumParams() == 1) &&
+ FT->getParamType(0)->isFloatTy())
+ return nullptr;
----------------
The FunctionType check doesn't seem necessary here.
================
Comment at: test/Transforms/Util/libcalls-fast-math-inf-loop.ll:1
+; RUN: opt -S -O2 -o - %s | FileCheck %s
+
----------------
Please don't use -O2 in tests... just test the specific pass you care about (in this case, instcombine).
https://reviews.llvm.org/D31806
More information about the llvm-commits
mailing list