forked from OSchip/llvm-project
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
This commit is contained in:
parent
a2ef047bd9
commit
5d4f0be5b8
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue