This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Builtin function roundeven folding implementation
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Tejas Joshi <tejasjoshi9673 at gmail dot com>
- Cc: <gcc-patches at gcc dot gnu dot org>, Martin Jambor <mjambor at suse dot cz>, <hubicka at ucw dot cz>
- Date: Fri, 9 Aug 2019 20:45:04 +0000
- Subject: Re: [PATCH] Builtin function roundeven folding implementation
- Ironport-sdr: tbAJxwn0ArrEyTxgKypOcA5FOgmKCi5UHelQy4AuZxi/wGGoLBWYP+y1phEzMWheMBbqzqisDp DPOYVTrfLgSto85+eAbKT/lLvV8UjaLceRJ+jOaazYhvDgWK0jcw6RTW/FHJkOsrms86PoRVdj hEqqN8NC6rhYLpIS/SartzU46isoxX7OYtP+Dt64Sr4iJvOofIFxNHeRutHD6Dn3V/1CDWTbNI z3ihk+NbrgrMMOATgmgPUE0SlsN3BbC8TESAuUEmV+1L8VYBklmlbNPfy1MK2o71R07N4Ni9Ys 5vY=
- Ironport-sdr: NGAxaRMOCsvnPz/yD0gkb2mcvJGwPPpx29AUcGEO/xDZG51gm79FKKndnDBIk2ak5DU3wbbQ31 WWA6hfofJic8V+PQjBm6Y1GGqFuVa60bRPJ5Wh95ejcnUE6gJdQiP+baL/uOeTdiU+TWRD1Xi7 bdOQEHssTyso72ciYowZ8Rnzg6/CSjo/K9nXZJzwJIRGu4Z0QDTcJk21c+9KGl6VuRDs3XQCf+ K/jRXPQbwXJRNbNrSQYz+qknKUeZhRQOEEgGBiZUVtpfEbhOT6vJSCXruuHqEtIbj/B6XjFHcA 3tM=
- References: <CACMrGjCu54zN+Smc7+3JF8MBZV76HXwaP-vk1HFTQGhRc=Toww@mail.gmail.com>
On Fri, 28 Jun 2019, Tejas Joshi wrote:
> + CASE_CFN_ROUNDEVEN:
> + CASE_CFN_ROUNDEVEN_FN:
> + if (!REAL_VALUE_ISNAN (*arg) || !flag_errno_math)
Checking flag_errno_math here does not make sense. roundeven never sets
errno (at least, TS 18661-1 makes it implementation-defined whether sNaN
input counts as a domain error, but I'm not aware of implementations that
make it a domain error and set errno, and typically GCC follows glibc in
such cases in the absence of known implementations requiring a different
approach).
The only case where you need to avoid folding is where the argument is a
signaling NaN (it's fine to fold for quiet NaNs). In that case, you need
to avoid folding to avoid losing an exception (if the user cares about
signaling NaNs, they probably care about exceptions) - so it still doesn't
matter whether the library implementation also sets errno or not.
(Yes, this means the existing ceil / floor / round checks should be
adjusted just to check for signaling NaN, though that's fairly cosmetic as
calls to those functions with quiet NaN argument still get folded via
match.pd. trunc ought also check for signaling NaN rather than folding
unconditionally, so all those functions should end up with the same
conditions for folding.)
> @@ -898,6 +907,10 @@ fold_const_call_ss (wide_int *result, combined_fn fn,
> return fold_const_conversion (result, real_round, arg,
> precision, format);
>
> + CASE_CFN_ROUNDEVEN:
> + CASE_CFN_ROUNDEVEN_FN:
> + return fold_const_conversion (result, real_roundeven, arg, precision, format);
> +
This is the version of fold_const_call_ss for functions returning a result
of integer type; roundeven returns an integer value in a floating-point
type. I don't think this code should be there, and I don't think this
version of the function should be called at all for roundeven.
--
Joseph S. Myers
joseph@codesourcery.com