diff --git a/clang/include/clang/Basic/Builtins.def b/clang/include/clang/Basic/Builtins.def --- a/clang/include/clang/Basic/Builtins.def +++ b/clang/include/clang/Basic/Builtins.def @@ -350,6 +350,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") @@ -1420,6 +1425,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) diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -2444,6 +2444,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: diff --git a/clang/test/CodeGen/builtins.c b/clang/test/CodeGen/builtins.c --- a/clang/test/CodeGen/builtins.c +++ b/clang/test/CodeGen/builtins.c @@ -411,6 +411,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