@@ -1984,6 +1984,7 @@ bool llvm::canConstantFoldCallTo(const CallBase *Call, const Function *F) {
19841984 switch (Name[0 ]) {
19851985 default :
19861986 return false ;
1987+ // clang-format off
19871988 case ' a' :
19881989 return Name == " acos" || Name == " acosf" ||
19891990 Name == " asin" || Name == " asinf" ||
@@ -2014,7 +2015,8 @@ bool llvm::canConstantFoldCallTo(const CallBase *Call, const Function *F) {
20142015 case ' r' :
20152016 return Name == " remainder" || Name == " remainderf" ||
20162017 Name == " rint" || Name == " rintf" ||
2017- Name == " round" || Name == " roundf" ;
2018+ Name == " round" || Name == " roundf" ||
2019+ Name == " roundeven" || Name == " roundevenf" ;
20182020 case ' s' :
20192021 return Name == " sin" || Name == " sinf" ||
20202022 Name == " sinh" || Name == " sinhf" ||
@@ -2052,6 +2054,7 @@ bool llvm::canConstantFoldCallTo(const CallBase *Call, const Function *F) {
20522054 case ' s' :
20532055 return Name == " __sinh_finite" || Name == " __sinhf_finite" ;
20542056 }
2057+ // clang-format on
20552058 }
20562059}
20572060
@@ -2516,7 +2519,8 @@ static Constant *ConstantFoldScalarCall1(StringRef Name,
25162519
25172520 // Use internal versions of these intrinsics.
25182521
2519- if (IntrinsicID == Intrinsic::nearbyint || IntrinsicID == Intrinsic::rint) {
2522+ if (IntrinsicID == Intrinsic::nearbyint || IntrinsicID == Intrinsic::rint ||
2523+ IntrinsicID == Intrinsic::roundeven) {
25202524 U.roundToIntegral (APFloat::rmNearestTiesToEven);
25212525 return ConstantFP::get (Ty->getContext (), U);
25222526 }
@@ -2988,6 +2992,8 @@ static Constant *ConstantFoldScalarCall1(StringRef Name,
29882992 case LibFunc_nearbyintf:
29892993 case LibFunc_rint:
29902994 case LibFunc_rintf:
2995+ case LibFunc_roundeven:
2996+ case LibFunc_roundevenf:
29912997 if (TLI->has (Func)) {
29922998 U.roundToIntegral (APFloat::rmNearestTiesToEven);
29932999 return ConstantFP::get (Ty->getContext (), U);
0 commit comments