Index: flang/lib/Evaluate/fold-real.cpp =================================================================== --- flang/lib/Evaluate/fold-real.cpp +++ flang/lib/Evaluate/fold-real.cpp @@ -144,6 +144,7 @@ } // TODO: dim, dot_product, fraction, matmul, // modulo, nearest, norm2, rrspacing, scale, + // __builtin_next_after/down/up, // set_exponent, spacing, transfer, // bessel_jn (transformational) and bessel_yn (transformational) return Expr{std::move(funcRef)}; Index: flang/lib/Evaluate/intrinsics.cpp =================================================================== --- flang/lib/Evaluate/intrinsics.cpp +++ flang/lib/Evaluate/intrinsics.cpp @@ -690,7 +690,7 @@ {{"a", ExtensibleDerived, Rank::anyOrAssumedRank}, {"b", ExtensibleDerived, Rank::anyOrAssumedRank}}, DefaultLogical, Rank::scalar, IntrinsicClass::inquiryFunction}, - {"scale", {{"x", SameReal}, {"i", AnyInt}}, SameReal}, + {"scale", {{"x", SameReal}, {"i", AnyInt}}, SameReal}, // == IEEE_SCALB() {"scan", {{"string", SameChar}, {"set", SameChar}, {"back", AnyLogical, Rank::elemental, Optionality::optional}, @@ -791,6 +791,9 @@ DefaultingKIND}, KINDInt}, {"__builtin_ieee_is_nan", {{"a", AnyFloating}}, DefaultLogical}, + {"__builtin_ieee_next_after", {{"x", SameReal}, {"y", AnyReal}}, SameReal}, + {"__builtin_ieee_next_down", {{"x", SameReal}}, SameReal}, + {"__builtin_ieee_next_up", {{"x", SameReal}}, SameReal}, {"__builtin_ieee_selected_real_kind", // alias for selected_real_kind {{"p", AnyInt, Rank::scalar}, {"r", AnyInt, Rank::scalar, Optionality::optional}, Index: flang/module/__fortran_builtins.f90 =================================================================== --- flang/module/__fortran_builtins.f90 +++ flang/module/__fortran_builtins.f90 @@ -42,6 +42,9 @@ procedure(type(__builtin_c_ptr)) :: __builtin_c_loc intrinsic :: __builtin_ieee_is_nan + intrinsic :: __builtin_ieee_next_after, __builtin_ieee_next_down, & + __builtin_ieee_next_up + intrinsic :: scale ! for ieee_scalb intrinsic :: __builtin_ieee_selected_real_kind intrinsic :: __builtin_ieee_support_datatype, & __builtin_ieee_support_denormal, __builtin_ieee_support_divide, & Index: flang/module/ieee_arithmetic.f90 =================================================================== --- flang/module/ieee_arithmetic.f90 +++ flang/module/ieee_arithmetic.f90 @@ -11,6 +11,10 @@ use __Fortran_builtins, only: & ieee_is_nan => __builtin_ieee_is_nan, & + ieee_next_after => __builtin_ieee_next_after, & + ieee_next_down => __builtin_ieee_next_down, & + ieee_next_up => __builtin_ieee_next_up, & + ieee_scalb => scale, & ieee_selected_real_kind => __builtin_ieee_selected_real_kind, & ieee_support_datatype => __builtin_ieee_support_datatype, & ieee_support_denormal => __builtin_ieee_support_denormal, &