OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [gcc/] [testsuite/] [gcc.dg/] [builtins-11.c] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 jlechner
/* Copyright (C) 2003 Free Software Foundation.
2
 
3
   Check that constant folding of built-in math functions doesn't
4
   break anything and produces the expected results.
5
 
6
   Written by Roger Sayle, 5th April 2003.  */
7
 
8
/* { dg-do link } */
9
/* { dg-options "-O2 -ffast-math" } */
10
 
11
extern void link_error(void);
12
 
13
extern double exp(double);
14
extern double sqrt(double);
15
extern double pow(double,double);
16
 
17
void test(double x, double y, double z)
18
{
19
  if (sqrt(x)*sqrt(x) != x)
20
    link_error ();
21
 
22
  if (sqrt(x)*sqrt(y) != sqrt(x*y))
23
    link_error ();
24
 
25
  if (exp(x)*exp(y) != exp(x+y))
26
    link_error ();
27
 
28
  if (pow(x,y)*pow(z,y) != pow(z*x,y))
29
    link_error ();
30
 
31
  if (pow(x,y)*pow(x,z) != pow(x,y+z))
32
    link_error ();
33
 
34
  if (x/exp(y) != x*exp(-y))
35
    link_error ();
36
 
37
  if (x/pow(y,z) != x*pow(y,-z))
38
    link_error ();
39
}
40
 
41
int main()
42
{
43
  test (2.0, 3.0, 4.0);
44
  return 0;
45
}
46
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.