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_fmaximum, "ddd", "Fnc") +BUILTIN(__builtin_fmaximumf, "fff", "Fnc") +BUILTIN(__builtin_fmaximumf16, "hhh", "Fnc") +BUILTIN(__builtin_fmaximuml, "LdLdLd", "Fnc") +BUILTIN(__builtin_fmaximumf128, "LLdLLdLLd", "Fnc") +BUILTIN(__builtin_fminimum, "ddd", "Fnc") +BUILTIN(__builtin_fminimumf, "fff", "Fnc") +BUILTIN(__builtin_fminimumf16, "hhh", "Fnc") +BUILTIN(__builtin_fminimuml, "LdLdLd", "Fnc") +BUILTIN(__builtin_fminimumf128, "LLdLLdLLd", "Fnc") BUILTIN(__builtin_hypot , "ddd" , "Fne") BUILTIN(__builtin_hypotf, "fff" , "Fne") BUILTIN(__builtin_hypotl, "LdLdLd", "Fne") @@ -1342,6 +1352,14 @@ LIBBUILTIN(fminf, "fff", "fnc", MATH_H, ALL_LANGUAGES) LIBBUILTIN(fminl, "LdLdLd", "fnc", MATH_H, ALL_LANGUAGES) +LIBBUILTIN(fmaximum, "ddd", "fnc", MATH_H, ALL_LANGUAGES) +LIBBUILTIN(fmaximumf, "fff", "fnc", MATH_H, ALL_LANGUAGES) +LIBBUILTIN(fmaximuml, "LdLdLd", "fnc", MATH_H, ALL_LANGUAGES) + +LIBBUILTIN(fminimum, "ddd", "fnc", MATH_H, ALL_LANGUAGES) +LIBBUILTIN(fminimumf, "fff", "fnc", MATH_H, ALL_LANGUAGES) +LIBBUILTIN(fminimuml, "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) Index: clang/lib/CodeGen/CGBuiltin.cpp =================================================================== --- clang/lib/CodeGen/CGBuiltin.cpp +++ clang/lib/CodeGen/CGBuiltin.cpp @@ -2345,6 +2345,30 @@ Intrinsic::minnum, Intrinsic::experimental_constrained_minnum)); + case Builtin::BIfmaximum: + case Builtin::BIfmaximumf: + case Builtin::BIfmaximuml: + case Builtin::BI__builtin_fmaximum: + case Builtin::BI__builtin_fmaximumf: + case Builtin::BI__builtin_fmaximumf16: + case Builtin::BI__builtin_fmaximuml: + case Builtin::BI__builtin_fmaximumf128: + return RValue::get(emitBinaryMaybeConstrainedFPBuiltin(*this, E, + Intrinsic::maximum, + Intrinsic::experimental_constrained_maximum)); + + case Builtin::BIfminimum: + case Builtin::BIfminimumf: + case Builtin::BIfminimuml: + case Builtin::BI__builtin_fminimum: + case Builtin::BI__builtin_fminimumf: + case Builtin::BI__builtin_fminimumf16: + case Builtin::BI__builtin_fminimuml: + case Builtin::BI__builtin_fminimumf128: + 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: Index: clang/test/CodeGen/builtins.c =================================================================== --- clang/test/CodeGen/builtins.c +++ clang/test/CodeGen/builtins.c @@ -329,6 +329,24 @@ resld = __builtin_fmaxl(LD, LD); // CHECK: call x86_fp80 @llvm.maxnum.f80 + resf = __builtin_fminimumf(F, F); + // CHECK: call float @llvm.minimum.f32 + + resd = __builtin_fminimum(D, D); + // CHECK: call double @llvm.minimum.f64 + + resld = __builtin_fminimuml(LD, LD); + // CHECK: call x86_fp80 @llvm.minimum.f80 + + resf = __builtin_fmaximumf(F, F); + // CHECK: call float @llvm.maximum.f32 + + resd = __builtin_fmaximum(D, D); + // CHECK: call double @llvm.maximum.f64 + + resld = __builtin_fmaximuml(LD, LD); + // CHECK: call x86_fp80 @llvm.maximum.f80 + resf = __builtin_fabsf(F); // CHECK: call float @llvm.fabs.f32