aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/other/vector-compare.C
blob: 03ff5fd7255a0c4d206192f9789b528fec9663aa (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
/* { dg-do compile { target c++11 } } */
/* { dg-options "-Wall" } */

// Check that we can compare vector types that really are the same through
// typedefs.

typedef float v4f __attribute__((vector_size(4*sizeof(float))));

template <class T> void eat (T&&) {}

template <class T, int n>
struct Vec
{
  typedef T type __attribute__((vector_size(4*sizeof(T))));

  template <class U>
  static void fun (type const& t, U& u) { eat (t > u); }
};

long long
f (v4f *x, v4f const *y)
{
  return ((*x < *y) | (*x <= *y))[2];
}

int main ()
{
  v4f x = {0,1,2,3};
  Vec<const volatile float,4>::type f = {-1,5,2,3.1};
  auto c = (x == f) == (x >= x);
  eat (c[3]);
  Vec<const volatile float,4>::fun (f, x);
  Vec<const volatile float,4>::fun (x, f);
  Vec<const volatile float,4>::fun (f, f);
  Vec<const volatile float,4>::fun (x, x);
}