aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.target/aarch64/vect-fmax-fmin.c
blob: 42600b7393d1c4edd4be69d094971952095d193c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/* { dg-do run } */
/* { dg-options "-O3 -ffast-math" } */

extern void abort (void);

#include "vect-fmax-fmin.x"

#include "vect-fmaxv-fminv.x"

#define DEFN_SETV(type) \
		set_vector_##type (pR##type a, type n)   \
		{ 				         \
		  int i;			         \
		  for (i=0; i<16; i++)		         \
		    a[i] = n;				 \
		}

#define DEFN_CHECKV(type) \
		void check_vector_##type (pR##type a, pR##type vec) \
		{						    \
		  int i;					    \
		  for (i=0; i<16; i++)				    \
		    if (a[i] != vec[i])				    \
		      abort ();					    \
		}

#define TEST2(fname, type) \
			set_vector_##type (c##type, 0.0);              \
			fname##_##type (a##type, b##type);             \
			check_vector_##type (c##type, fname##_##type##_vector);

#define TEST3(fname, type) \
			set_vector_##type (c##type, 0.0);              \
			fname##_##type (a##type, b##type, c##type);    \
			check_vector_##type (c##type, fname##_##type##_vector);

#define TEST(fname, N) \
		TEST##N (fname, F32); \
		TEST##N (fname, F64);

typedef float F32;
typedef double F64;

DEFN_SETV (F32)
DEFN_SETV (F64)

DEFN_CHECKV (F32)
DEFN_CHECKV (F64)

int main (void)
{

  F32 aF32[16];
  F32 bF32[16];
  F32 cF32[16];

  F64 aF64[16];
  F64 bF64[16];
  F64 cF64[16];
  int i;

  /* Golden vectors.  */
  F32 max_F32_vector[] = { 15.0, 14.0, 13.0, 12.0, 11.0, 10.0, 9.0, 8.0,
			   8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0 };

  F64 max_F64_vector[] = { 15.0, 14.0, 13.0, 12.0, 11.0, 10.0, 9.0, 8.0,
			   8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0 };

  F32 min_F32_vector[] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0,
			   7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0, 0.0 };

  F64 min_F64_vector[] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0,
			   7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0, 0.0 };

  F32 minv_F32_value = 0.0f;
  F32 maxv_F32_value = 15.0f;

  F64 minv_F64_value = 0.0;
  F64 maxv_F64_value = 15.0;

  /* Setup input vectors.  */
  for (i=0; i<16; i++)
    {
      aF32[i] = (float)(15-i);
      bF32[i] = (float)i;
      aF64[i] = (double)(15-i);
      bF64[i] = (double)i;
    }

  TEST (max, 3);
  TEST (min, 3);

  /* Test across lanes ops.  */
  if (maxv_f32 (max_F32_vector) != maxv_F32_value)
    abort ();
  if (minv_f32 (min_F32_vector) != minv_F32_value)
    abort ();

  if (maxv_f64 (max_F64_vector) != maxv_F64_value)
    abort ();
  if (minv_f64 (min_F64_vector) != minv_F64_value)
    abort ();

  return 0;
}