gcc/libgomp/testsuite/libgomp.c/examples-4/simd-7.c
Maxim Blumenthal 27c4ac7db7 re PR libgomp/66950 (FAIL: libgomp.fortran/examples-4/simd-7.f90 -O0 execution test)
2015-07-22  Maxim Blumenthal  <maxim.blumenthal@intel.com>

	PR libgomp/66950
	* testsuite/libgomp.c/examples-4/simd-7.c (N): Change to 30 from 45.
	(fib_ref): New function.
	(fib): Correct corner cases in the recursion.
	(main): Replace the non-simd loop with fib_ref call.
	* testsuite/libgomp.fortran/examples-4/simd-7.f90: (fib_ref): New
	subroutine.
	(fibonacci): Lower the parameter N to 30.  Correct accordingly check
	for the last array element value.  Replace the non-simd loop with
	fib_ref call.  Remove redundant b_ref array.  Remove the comparison
	of the last array element with according Fibonacci sequence element.
	(fib): Correct corner cases in the recursion.

From-SVN: r226080
2015-07-22 17:19:31 +00:00

51 lines
750 B
C

/* { dg-do run { target vect_simd_clones } } */
/* { dg-additional-options "-msse2" { target sse2_runtime } } */
/* { dg-additional-options "-mavx" { target avx_runtime } } */
#include <stdio.h>
#include <stdlib.h>
#define N 30
int a[N], a_ref[N], b[N];
#pragma omp declare simd inbranch
int fib( int n )
{
if (n <= 1)
return n;
else
return fib(n-1) + fib(n-2);
}
void fib_ref()
{
int i;
a_ref[0] = 0;
a_ref[1] = 1;
for (i=2; i < N; i++)
a_ref[i] = a_ref[i-2] + a_ref[i-1];
}
int main(void)
{
int i;
#pragma omp simd
for (i=0; i < N; i++)
b[i] = i;
#pragma omp simd
for (i=0; i < N; i++)
a[i] = fib(b[i]);
fib_ref ();
for (i=0; i < N; i++)
if (a[i] != a_ref[i])
abort ();
return 0;
}