OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.dg/] [builtins-10.c] - Blame information for rev 645

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
/* 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, 2nd 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 log(double);
15
extern double sqrt(double);
16
extern double pow(double,double);
17
extern double fabs(double);
18
 
19
void test(double x)
20
{
21
  if (sqrt(pow(x,4.0)) != x*x)
22
    link_error ();
23
 
24
  if (pow(sqrt(x),4.0) != x*x)
25
    link_error ();
26
 
27
  if (pow(pow(x,4.0),0.25) != x)
28
    link_error ();
29
}
30
 
31
void test2(double x, double y, double z)
32
{
33
  if (sqrt(pow(x,y)) != pow(fabs(x),y*0.5))
34
    link_error ();
35
 
36
  if (log(pow(x,y)) != y*log(x))
37
    link_error ();
38
 
39
  if (pow(exp(x),y) != exp(x*y))
40
    link_error ();
41
 
42
  if (pow(sqrt(x),y) != pow(x,y*0.5))
43
    link_error ();
44
 
45
  if (pow(pow(x,y),z) != pow(x,y*z))
46
    link_error ();
47
}
48
 
49
int main()
50
{
51
  test (2.0);
52
  test2 (2.0, 3.0, 4.0);
53
  return 0;
54
}
55
 

powered by: WebSVN 2.1.0

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