Index: include/clang/Basic/Builtins.def =================================================================== --- include/clang/Basic/Builtins.def +++ include/clang/Basic/Builtins.def @@ -916,6 +916,14 @@ 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) Index: lib/CodeGen/CGBuiltin.cpp =================================================================== --- lib/CodeGen/CGBuiltin.cpp +++ lib/CodeGen/CGBuiltin.cpp @@ -903,6 +903,12 @@ 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 Index: test/CodeGen/builtins.c =================================================================== --- test/CodeGen/builtins.c +++ test/CodeGen/builtins.c @@ -220,6 +220,10 @@ // 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