Fix warning with -Wsign-compare -Wsystem-headers
[official-gcc.git] / gcc / testsuite / gcc.target / bfin / arith.c
blob35029ed32d2b09a3919a4156e5c06b8099ea1551
1 extern void abort (void);
2 extern void exit (int);
4 typedef short __v2hi __attribute ((vector_size(4)));
5 typedef __v2hi fract2x16;
6 typedef short fract16;
8 int main ()
10 fract2x16 a, b, c, d;
11 fract16 t1, t2;
12 a = __builtin_bfin_compose_2x16 (0x3000, 0x2000);
13 b = __builtin_bfin_compose_2x16 (0x7000, 0x5000);
14 c = __builtin_bfin_compose_2x16 (0x7000, 0xc000);
16 d = __builtin_bfin_add_fr2x16 (a, b);
17 t1 = __builtin_bfin_extract_lo (d);
18 t2 = __builtin_bfin_extract_hi (d);
19 if (t1 != 0x7000 || t2 != 0x7fff)
20 abort ();
22 d = __builtin_bfin_sub_fr2x16 (a, b);
23 t1 = __builtin_bfin_extract_lo (d);
24 t2 = __builtin_bfin_extract_hi (d);
25 if (t1 != -0x3000 || t2 != -0x4000)
26 abort ();
28 d = __builtin_bfin_negate_fr2x16 (c);
29 t1 = __builtin_bfin_extract_lo (d);
30 t2 = __builtin_bfin_extract_hi (d);
31 if (t1 != 0x4000 || t2 != -0x7000)
32 abort ();
34 if (__builtin_bfin_add_fr1x32 (0x7fffffff, 1) != 0x7fffffff)
35 abort ();
37 if (__builtin_bfin_add_fr1x32 (0x80000000, -1) != 0x80000000)
38 abort ();
40 if (__builtin_bfin_add_fr1x32 (0x80000001, -1) != 0x80000000)
41 abort ();
43 if (__builtin_bfin_add_fr1x32 (0xFEDCBA98, 0x11111111) != 0x0FEDCBA9)
44 abort ();
46 exit (0);