diff options
author | Dehao Chen <dehao@google.com> | 2016-09-14 17:34:14 +0000 |
---|---|---|
committer | Dehao Chen <dehao@google.com> | 2016-09-14 17:34:14 +0000 |
commit | 5d4f0be5b821063ef9b9e97b58757c79156e1977 (patch) | |
tree | 9de3f2a7d0f04b392d76126256b6f6901bb7bebe | |
parent | a2ef047bd929a74011a9bc5eddd2a5a6a3664ec9 (diff) | |
download | bcm5719-llvm-5d4f0be5b821063ef9b9e97b58757c79156e1977.tar.gz bcm5719-llvm-5d4f0be5b821063ef9b9e97b58757c79156e1977.zip |
Convert finite to builtin
Summary: This patch converts finite/__finite to builtin functions so that it will be inlined by compiler.
Reviewers: hfinkel, davidxl, efriedma
Subscribers: efriedma, llvm-commits
Differential Revision: https://reviews.llvm.org/D24483
llvm-svn: 281509
-rw-r--r-- | clang/include/clang/Basic/Builtins.def | 8 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGBuiltin.cpp | 6 | ||||
-rw-r--r-- | clang/test/CodeGen/builtins.c | 4 |
3 files changed, 18 insertions, 0 deletions
diff --git a/clang/include/clang/Basic/Builtins.def b/clang/include/clang/Basic/Builtins.def index 5112284866d..7316901ab86 100644 --- a/clang/include/clang/Basic/Builtins.def +++ b/clang/include/clang/Basic/Builtins.def @@ -937,6 +937,14 @@ LIBBUILTIN(fabs, "dd", "fnc", "math.h", ALL_LANGUAGES) LIBBUILTIN(fabsf, "ff", "fnc", "math.h", ALL_LANGUAGES) LIBBUILTIN(fabsl, "LdLd", "fnc", "math.h", ALL_LANGUAGES) +LIBBUILTIN(finite, "id", "fnc", "math.h", GNU_LANG) +LIBBUILTIN(finitef, "if", "fnc", "math.h", GNU_LANG) +LIBBUILTIN(finitel, "iLd", "fnc", "math.h", GNU_LANG) +// glibc's math.h generates calls to __finite +LIBBUILTIN(__finite, "id", "fnc", "math.h", ALL_LANGUAGES) +LIBBUILTIN(__finitef, "if", "fnc", "math.h", ALL_LANGUAGES) +LIBBUILTIN(__finitel, "iLd", "fnc", "math.h", ALL_LANGUAGES) + LIBBUILTIN(fmod, "ddd", "fne", "math.h", ALL_LANGUAGES) LIBBUILTIN(fmodf, "fff", "fne", "math.h", ALL_LANGUAGES) LIBBUILTIN(fmodl, "LdLdLd", "fne", "math.h", ALL_LANGUAGES) diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 94be5361e94..27c0b837766 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -903,6 +903,12 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, return RValue::get(Builder.CreateZExt(V, ConvertType(E->getType()))); } + case Builtin::BIfinite: + case Builtin::BI__finite: + case Builtin::BIfinitef: + case Builtin::BI__finitef: + case Builtin::BIfinitel: + case Builtin::BI__finitel: case Builtin::BI__builtin_isinf: case Builtin::BI__builtin_isfinite: { // isinf(x) --> fabs(x) == infinity diff --git a/clang/test/CodeGen/builtins.c b/clang/test/CodeGen/builtins.c index 405f2199af1..7d2a5d80e40 100644 --- a/clang/test/CodeGen/builtins.c +++ b/clang/test/CodeGen/builtins.c @@ -220,6 +220,10 @@ void test_float_builtins(float F, double D, long double LD) { // CHECK: call float @llvm.fabs.f32(float // CHECK: fcmp one float {{.*}}, 0x7FF0000000000000 + res = finite(D); + // CHECK: call double @llvm.fabs.f64(double + // CHECK: fcmp one double {{.*}}, 0x7FF0000000000000 + res = __builtin_isnormal(F); // CHECK: fcmp oeq float // CHECK: call float @llvm.fabs.f32(float |