FSF GCC merge 02/23/03
[official-gcc.git] / gcc / testsuite / g77.dg / 20010216-1.f
blob150dc9f016ac511fd1ff2ccf773eab06853a98b0
1 C Test for bug in reg-stack handling conditional moves.
2 C Reported by Tim Prince <tprince@computer.org>
4 C { dg-do run { target "i[6789]86-*-*" } }
5 C { dg-options "-ffast-math -march=pentiumpro" }
7 double precision function foo(x, y)
8 implicit none
9 double precision x, y
10 double precision a, b, c, d
11 if (x /= y) then
12 if (x * y >= 0) then
13 a = abs(x)
14 b = abs(y)
15 c = max(a, b)
16 d = min(a, b)
17 foo = 1 - d/c
18 else
19 foo = 1
20 end if
21 else
22 foo = 0
23 end if
24 end
26 program test
27 implicit none
29 integer ntests
30 parameter (ntests=7)
31 double precision tolerance
32 parameter (tolerance=1.0D-6)
34 C Each column is a pair of values to feed to foo,
35 C and its expected return value.
36 double precision a(ntests) /1, -23, -1, 1, 9, 10, -9/
37 double precision b(ntests) /1, -23, 12, -12, 10, 9, -10/
38 double precision x(ntests) /0, 0, 1, 1, 0.1, 0.1, 0.1/
40 double precision foo
41 double precision result
42 integer i
44 do i = 1, ntests
45 result = foo(a(i), b(i))
46 if (abs(result - x(i)) > tolerance) then
47 print *, i, a(i), b(i), x(i), result
48 call abort
49 end if
50 end do
51 end