Debian Codegraph @

gcc/testsuite/g++.dg/other/vector-compare.C

raw
1 /* { dg-do compile { target c++11 } } */
2 /* { dg-options "-Wall -Wno-tautological-compare" } */
3
4 // Check that we can compare vector types that really are the same through
5 // typedefs.
6
7 typedef float v4f __attribute__((vector_size(4*sizeof(float))));
8
9 template <class T> void eat (T&&) {}
10
11 template <class T, int n>
12 struct Vec
13 {
14 typedef T type __attribute__((vector_size(4*sizeof(T))));
15
16 template <class U>
17 static void fun (type const& t, U& u) { eat (t > u); }
18 };
19
20 long long
21 f (v4f *x, v4f const *y)
22 {
23 return ((*x < *y) | (*x <= *y))[2];
24 }
25
26 int main ()
27 {
28 v4f x = {0,1,2,3};
29 Vec<const volatile float,4>::type f = {-1,5,2,3.1};
30 auto c = (x == f) == (x >= x);
31 eat (c[3]);
32 Vec<const volatile float,4>::fun (f, x);
33 Vec<const volatile float,4>::fun (x, f);
34 Vec<const volatile float,4>::fun (f, f);
35 Vec<const volatile float,4>::fun (x, x);
36 }