| 1 |
! { dg-do compile } |
| 2 |
! { dg-require-effective-target vect_float } |
| 3 |
! { dg-require-effective-target vect_intfloat_cvt } |
| 4 |
! { dg-additional-options "-ffast-math" } |
| 5 |
|
| 6 |
program calcpi |
| 7 |
|
| 8 |
implicit none |
| 9 |
real(kind=4):: h,x,sum,pi |
| 10 |
integer:: n,i |
| 11 |
real(kind=4):: f |
| 12 |
|
| 13 |
f(x) = 4.0/(1.0+x**2) |
| 14 |
|
| 15 |
n = 2100000000 |
| 16 |
|
| 17 |
h= 1.0 / n |
| 18 |
sum = 0.0 |
| 19 |
DO i=1, n |
| 20 |
x = h * (i-0.5) |
| 21 |
sum = sum + f(x) |
| 22 |
END DO |
| 23 |
pi = h * sum |
| 24 |
write(*,*) 'Pi=',pi |
| 25 |
|
| 26 |
end program calcpi |
| 27 |
|
| 28 |
! { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } |