real: Fix roundeven on inf/nan [PR93663]
authorJakub Jelinek <jakub@redhat.com>
Wed, 12 Feb 2020 21:14:27 +0000 (22:14 +0100)
committerJakub Jelinek <jakub@redhat.com>
Wed, 12 Feb 2020 21:15:40 +0000 (22:15 +0100)
commit3f3932a0ec875cb7cca187018f3f8f05f2519d3e
treea87f5f837e40faeb1209cda65f5acce18836fc3d
parentb32a3f324367ca470aaec1866abe7edf5616bb7c
real: Fix roundeven on inf/nan [PR93663]

As can be seen in the testcase, roundeven with inf or nan arguments
ICE because of those asserts where nothing prevents from is_halfway_below
being called with those arguments.

The following patch fixes that by just returning false for rvc_inf/rvc_nan
like it returns for rvc_zero, so that we handle roundeven with all those
values as round.  Inf/NaN are not halfway in between two integers...

2020-02-12  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/93663
* real.c (is_even): Make static.  Function comment fix.
(is_halfway_below): Make static, don't assert R is not inf/nan,
instead return false for those.  Small formatting fixes.

* gcc.dg/torture/builtin-round-roundeven.c (main): Add tests
for DBL_MAX, inf, their negations and nan.
gcc/ChangeLog
gcc/real.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/builtin-round-roundeven.c