* gcc.dg/builtins-29.c: New test case.

From-SVN: r76444
This commit is contained in:
Roger Sayle 2004-01-23 18:37:16 +00:00 committed by Roger Sayle
parent 04b8f97f29
commit 92c7bc2abc
3 changed files with 100 additions and 2 deletions

View File

@ -36,8 +36,6 @@
round, roundf and roundl.
(fold_builtin): Call fold_builtin_round for BUILT_IN_ROUND{,F,L}.
* gcc.dg/builtins-29.c: New test case.
2004-01-23 Alexandre Oliva <aoliva@redhat.com>
PR optimization/13819

View File

@ -1,3 +1,7 @@
2004-01-23 Roger Sayle <roger@eyesopen.com>
* gcc.dg/builtins-29.c: New test case.
2004-01-23 Zack Weinberg <zack@codesourcery.com>
PR 18314

View File

@ -0,0 +1,96 @@
/* Copyright (C) 2004 Free Software Foundation.
Check that constant folding of round, roundf and roundl math functions
doesn't break anything and produces the expected results.
Written by Roger Sayle, 22nd January 2004. */
/* { dg-do link } */
/* { dg-options "-O2" } */
extern void link_error(void);
extern double round(double);
extern float roundf(float);
extern long double roundl(long double);
void test()
{
if (round (0.0) != 0.0)
link_error ();
if (round (6.0) != 6.0)
link_error ();
if (round (-8.0) != -8.0)
link_error ();
if (round (3.2) != 3.0)
link_error ();
if (round (-2.8) != -3.0)
link_error ();
if (round (0.01) != 0.0)
link_error ();
if (round (-0.7) != -1.0)
link_error ();
if (round (2.5) != 3.0)
link_error ();
if (round (-1.5) != -2.0)
link_error ();
}
void testf()
{
if (roundf (0.0f) != 0.0f)
link_error ();
if (roundf (6.0f) != 6.0f)
link_error ();
if (roundf (-8.0f) != -8.0f)
link_error ();
if (roundf (3.2f) != 3.0f)
link_error ();
if (roundf (-2.8f) != -3.0f)
link_error ();
if (roundf (0.01f) != 0.0f)
link_error ();
if (roundf (-0.7f) != -1.0f)
link_error ();
if (roundf (2.5f) != 3.0f)
link_error ();
if (roundf (-1.5f) != -2.0f)
link_error ();
}
void testl()
{
if (roundl (0.0l) != 0.0l)
link_error ();
if (roundl (6.0l) != 6.0l)
link_error ();
if (roundl (-8.0l) != -8.0l)
link_error ();
if (roundl (3.2l) != 3.0l)
link_error ();
if (roundl (-2.8l) != -3.0l)
link_error ();
if (roundl (0.01l) != 0.0l)
link_error ();
if (roundl (-0.7l) != -1.0l)
link_error ();
if (roundl (2.5l) != 3.0l)
link_error ();
if (roundl (-1.5l) != -2.0l)
link_error ();
}
int main()
{
test ();
testf ();
testl ();
return 0;
}