OSDN Git Service

PR target/50740
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.target / bfin / arith.c
1 extern void abort (void);
2 extern void exit (int);
3
4 typedef short  __v2hi __attribute ((vector_size(4)));
5 typedef __v2hi fract2x16;
6 typedef short fract16;
7
8 int main ()
9 {
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);
15
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 ();
21
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 ();
27
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 ();
33   
34   if (__builtin_bfin_add_fr1x32 (0x7fffffff, 1) != 0x7fffffff)
35     abort ();
36
37   if (__builtin_bfin_add_fr1x32 (0x80000000, -1) != 0x80000000)
38     abort ();
39     
40   if (__builtin_bfin_add_fr1x32 (0x80000001, -1) != 0x80000000)
41     abort ();
42     
43   if (__builtin_bfin_add_fr1x32 (0xFEDCBA98, 0x11111111) != 0x0FEDCBA9)
44     abort ();
45     
46   exit (0);
47 }
48