+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.
+
2020-02-12 Martin Sebor <msebor@redhat.com>
PR middle-end/93646
real_convert (r, fmt, r);
}
-/* Return true including 0 if integer part of R is even, else return
+/* Return true (including 0) if integer part of R is even, else return
false. The function is not valid for rvc_inf and rvc_nan classes. */
-bool
+static bool
is_even (REAL_VALUE_TYPE *r)
{
gcc_assert (r->cl != rvc_inf);
}
/* Return true if R is halfway between two integers, else return
- false. The function is not valid for rvc_inf and rvc_nan classes. */
+ false. */
-bool
+static bool
is_halfway_below (const REAL_VALUE_TYPE *r)
{
- gcc_assert (r->cl != rvc_inf);
- gcc_assert (r->cl != rvc_nan);
- int i;
-
- if (r->cl == rvc_zero)
+ if (r->cl != rvc_normal)
return false;
/* For numbers (-0.5,0) and (0,0.5). */
unsigned int n = SIGNIFICAND_BITS - REAL_EXP (r) - 1;
int w = n / HOST_BITS_PER_LONG;
- for (i = 0; i < w; ++i)
+ for (int i = 0; i < w; ++i)
if (r->sig[i] != 0)
return false;
- unsigned long num = ((unsigned long)1 << (n % HOST_BITS_PER_LONG));
+ unsigned long num = 1UL << (n % HOST_BITS_PER_LONG);
- if (((r->sig[w] & num) != 0) && ((r->sig[w] & (num-1)) == 0))
+ if ((r->sig[w] & num) != 0 && (r->sig[w] & (num - 1)) == 0)
return true;
}
return false;
+2020-02-12 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/93663
+ * gcc.dg/torture/builtin-round-roundeven.c (main): Add tests
+ for DBL_MAX, inf, their negations and nan.
+
2020-02-12 Martin Sebor <msebor@redhat.com>
PR middle-end/93646
TEST(roundeven, -1.5, -2);
TEST(roundeven, 3.499, 3);
TEST(roundeven, 3.501, 4);
+ TEST(roundeven, __DBL_MAX__, __DBL_MAX__);
+ TEST(roundeven, -__DBL_MAX__, -__DBL_MAX__);
+ TEST(roundeven, __builtin_inf (), __builtin_inf ());
+ TEST(roundeven, -__builtin_inf (), -__builtin_inf ());
+
+ if (!__builtin_isnan (__builtin_roundeven (__builtin_nan (""))))
+ link_error (__LINE__);
if (__builtin_copysign (1, __builtin_roundeven (-0.5)) != -1)
link_error (__LINE__);
link_error (__LINE__);
if (__builtin_copysign (-1, __builtin_roundeven (0.25)) != 1)
link_error (__LINE__);
- return 0;
+ return 0;
}
-