Index: clang/include/clang/Basic/Builtins.def =================================================================== --- clang/include/clang/Basic/Builtins.def +++ clang/include/clang/Basic/Builtins.def @@ -269,6 +269,16 @@ BUILTIN(__builtin_fminf16, "hhh", "FncE") BUILTIN(__builtin_fminl, "LdLdLd", "FncE") BUILTIN(__builtin_fminf128, "LLdLLdLLd", "FncE") +BUILTIN(__builtin_fmaxm, "ddd", "Fnc") +BUILTIN(__builtin_fmaxmf, "fff", "Fnc") +BUILTIN(__builtin_fmaxmf16, "hhh", "Fnc") +BUILTIN(__builtin_fmaxml, "LdLdLd", "Fnc") +BUILTIN(__builtin_fmaxmf128, "LLdLLdLLd", "Fnc") +BUILTIN(__builtin_fminm, "ddd", "Fnc") +BUILTIN(__builtin_fminmf, "fff", "Fnc") +BUILTIN(__builtin_fminmf16, "hhh", "Fnc") +BUILTIN(__builtin_fminml, "LdLdLd", "Fnc") +BUILTIN(__builtin_fminmf128, "LLdLLdLLd", "Fnc") BUILTIN(__builtin_hypot , "ddd" , "Fne") BUILTIN(__builtin_hypotf, "fff" , "Fne") BUILTIN(__builtin_hypotl, "LdLdLd", "Fne") @@ -350,6 +360,11 @@ BUILTIN(__builtin_roundf16, "hh" , "Fnc") BUILTIN(__builtin_roundl, "LdLd" , "Fnc") BUILTIN(__builtin_roundf128, "LLdLLd" , "Fnc") +BUILTIN(__builtin_roundeven, "dd" , "Fnc") +BUILTIN(__builtin_roundevenf, "ff" , "Fnc") +BUILTIN(__builtin_roundevenf16, "hh" , "Fnc") +BUILTIN(__builtin_roundevenl, "LdLd" , "Fnc") +BUILTIN(__builtin_roundevenf128, "LLdLLd" , "Fnc") BUILTIN(__builtin_scalbln , "ddLi", "Fne") BUILTIN(__builtin_scalblnf, "ffLi", "Fne") BUILTIN(__builtin_scalblnl, "LdLdLi", "Fne") @@ -1342,6 +1357,14 @@ LIBBUILTIN(fminf, "fff", "fnc", MATH_H, ALL_LANGUAGES) LIBBUILTIN(fminl, "LdLdLd", "fnc", MATH_H, ALL_LANGUAGES) +LIBBUILTIN(fmaxm, "ddd", "fnc", MATH_H, ALL_LANGUAGES) +LIBBUILTIN(fmaxmf, "fff", "fnc", MATH_H, ALL_LANGUAGES) +LIBBUILTIN(fmaxml, "LdLdLd", "fnc", MATH_H, ALL_LANGUAGES) + +LIBBUILTIN(fminm, "ddd", "fnc", MATH_H, ALL_LANGUAGES) +LIBBUILTIN(fminmf, "fff", "fnc", MATH_H, ALL_LANGUAGES) +LIBBUILTIN(fminml, "LdLdLd", "fnc", MATH_H, ALL_LANGUAGES) + LIBBUILTIN(hypot, "ddd", "fne", MATH_H, ALL_LANGUAGES) LIBBUILTIN(hypotf, "fff", "fne", MATH_H, ALL_LANGUAGES) LIBBUILTIN(hypotl, "LdLdLd", "fne", MATH_H, ALL_LANGUAGES) @@ -1420,6 +1443,10 @@ LIBBUILTIN(roundf, "ff", "fnc", MATH_H, ALL_LANGUAGES) LIBBUILTIN(roundl, "LdLd", "fnc", MATH_H, ALL_LANGUAGES) +LIBBUILTIN(roundeven, "dd", "fnc", MATH_H, ALL_LANGUAGES) +LIBBUILTIN(roundevenf, "ff", "fnc", MATH_H, ALL_LANGUAGES) +LIBBUILTIN(roundevenl, "LdLd", "fnc", MATH_H, ALL_LANGUAGES) + LIBBUILTIN(scalbln, "ddLi", "fne", MATH_H, ALL_LANGUAGES) LIBBUILTIN(scalblnf, "ffLi", "fne", MATH_H, ALL_LANGUAGES) LIBBUILTIN(scalblnl, "LdLdLi", "fne", MATH_H, ALL_LANGUAGES) Index: clang/lib/CodeGen/CGBuiltin.cpp =================================================================== --- clang/lib/CodeGen/CGBuiltin.cpp +++ clang/lib/CodeGen/CGBuiltin.cpp @@ -2345,6 +2345,31 @@ Intrinsic::minnum, Intrinsic::experimental_constrained_minnum)); + case Builtin::BIfmaxm: + case Builtin::BIfmaxmf: + case Builtin::BIfmaxml: + case Builtin::BI__builtin_fmaxm: + case Builtin::BI__builtin_fmaxmf: + case Builtin::BI__builtin_fmaxmf16: + case Builtin::BI__builtin_fmaxml: + case Builtin::BI__builtin_fmaxmf128: + return RValue::get(emitBinaryMaybeConstrainedFPBuiltin(*this, E, + Intrinsic::maximum, + Intrinsic::experimental_constrained_maximum)); + + case Builtin::BIfminm: + case Builtin::BIfminmf: + case Builtin::BIfminml: + case Builtin::BI__builtin_fminm: + case Builtin::BI__builtin_fminmf: + case Builtin::BI__builtin_fminmf16: + case Builtin::BI__builtin_fminml: + case Builtin::BI__builtin_fminmf128: + return RValue::get(emitBinaryMaybeConstrainedFPBuiltin(*this, E, + Intrinsic::minimum, + Intrinsic::experimental_constrained_minimum)); + + // fmod() is a special-case. It maps to the frem instruction rather than an // LLVM intrinsic. case Builtin::BIfmod: @@ -2444,6 +2469,18 @@ Intrinsic::round, Intrinsic::experimental_constrained_round)); + case Builtin::BIroundeven: + case Builtin::BIroundevenf: + case Builtin::BIroundevenl: + case Builtin::BI__builtin_roundeven: + case Builtin::BI__builtin_roundevenf: + case Builtin::BI__builtin_roundevenf16: + case Builtin::BI__builtin_roundevenl: + case Builtin::BI__builtin_roundevenf128: + return RValue::get(emitUnaryMaybeConstrainedFPBuiltin(*this, E, + Intrinsic::roundeven, + Intrinsic::experimental_constrained_roundeven)); + case Builtin::BIsin: case Builtin::BIsinf: case Builtin::BIsinl: Index: clang/test/CodeGen/builtins.c =================================================================== --- clang/test/CodeGen/builtins.c +++ clang/test/CodeGen/builtins.c @@ -328,6 +328,24 @@ resld = __builtin_fmaxl(LD, LD); // CHECK: call x86_fp80 @llvm.maxnum.f80 + + resf = __builtin_fminmf(F, F); + // CHECK: call float @llvm.minimum.f32 + + resd = __builtin_fminm(D, D); + // CHECK: call double @llvm.minimum.f64 + + resld = __builtin_fminml(LD, LD); + // CHECK: call x86_fp80 @llvm.minimum.f80 + + resf = __builtin_fmaxmf(F, F); + // CHECK: call float @llvm.maximum.f32 + + resd = __builtin_fmaxm(D, D); + // CHECK: call double @llvm.maximum.f64 + + resld = __builtin_fmaxml(LD, LD); + // CHECK: call x86_fp80 @llvm.maximum.f80 resf = __builtin_fabsf(F); // CHECK: call float @llvm.fabs.f32 @@ -411,6 +429,15 @@ resld = __builtin_roundl(LD); // CHECK: call x86_fp80 @llvm.round.f80 + resf = __builtin_roundevenf(F); + // CHECK: call float @llvm.roundeven.f32 + + resd = __builtin_roundeven(D); + // CHECK: call double @llvm.roundeven.f64 + + resld = __builtin_roundevenl(LD); + // CHECK: call x86_fp80 @llvm.roundeven.f80 + resli = __builtin_lroundf (F); // CHECK: call i64 @llvm.lround.i64.f32