xref: /openbsd-src/gnu/usr.bin/gcc/gcc/testsuite/gcc.dg/simd-1.c (revision c87b03e512fc05ed6e0222f6fb0ae86264b1d05b)
1 /* { dg-do compile } */
2 /* { dg-options "-Wall" } */
3 
4 /* Origin: Aldy Hernandez <aldyh@redhat.com>.  */
5 /* Purpose: Program to test generic SIMD support.  */
6 
7 typedef int __attribute__((mode(V4SI))) v4si;
8 typedef int __attribute__((mode(V8HI))) v8hi;
9 typedef int __attribute__((mode(V2SI))) v2si;
10 typedef unsigned int __attribute__((mode(V4SI))) uv4si;
11 
12 v4si a, b;
13 v2si c, d;
14 v8hi e;
15 uv4si f;
16 
17 int foo __attribute__((mode(DI)));
18 int foo1 __attribute__((mode(SI)));
19 int foo2 __attribute__((mode(V4HI)));
20 
21 void
hanneke()22 hanneke ()
23 {
24   /* Assignment.  */
25   a = b;
26 
27   /* Assignment of different types.  */
28   b = c; /* { dg-error "incompatible types in assignment" } */
29   d = a; /* { dg-error "incompatible types in assignment" } */
30 
31   /* Casting between SIMDs of the same size.  */
32   e = (typeof (e)) a;
33 
34   /* Different signed SIMD assignment.  */
35   f = a; /* { dg-error "incompatible types in assignment" } */
36 
37   /* Casted different signed SIMD assignment.  */
38   f = (uv4si) a;
39 
40   /* Assignment between scalar and SIMD of different size.  */
41   foo = a; /* { dg-error "incompatible types in assignment" } */
42 
43   /* Casted assignment between scalar and SIMD of same size.  */
44   foo = (typeof (foo)) foo2;
45 
46   /* Casted assignment between scalar and SIMD of different size.  */
47   foo1 = (typeof (foo1)) foo2; /* { dg-error "can't convert between vector values of different size" } */
48 
49   /* Operators on compatible SIMD types.  */
50   a += b + b;
51   a -= b;
52   a *= b;
53   a /= b;
54   a = -b;
55 
56   /* Operators on incompatible SIMD types.  */
57   a = b + c; /* { dg-error "can't convert between vector values of different size" } */
58   a = b - c; /* { dg-error "can't convert between vector values of different size" } */
59   a = b * c; /* { dg-error "can't convert between vector values of different size" } */
60   a = b / c; /* { dg-error "can't convert between vector values of different size" } */
61 }
62