summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/bfin/shift.c
blob: 4a0e9175cc0943382e16bac1ceebaf712de206f7 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
extern void abort (void);
extern void exit (int);

typedef short  __v2hi __attribute ((vector_size(4)));
typedef __v2hi fract2x16;
typedef short fract16;

int main ()
{
  fract2x16 a, b, c, d;
  fract16 t1, t2;
  a = __builtin_bfin_compose_2x16 (0xe005, 0x1000);
  b = __builtin_bfin_compose_2x16 (0x7000, 0x5000);
  c = __builtin_bfin_compose_2x16 (0x7000, 0xc000);

  d = __builtin_bfin_shl_fr2x16 (c, 2);
  t1 = __builtin_bfin_extract_lo (d);
  t2 = __builtin_bfin_extract_hi (d);
  if ((unsigned short)t1 != 0x8000 || t2 != 0x7fff)
    abort ();

  d = __builtin_bfin_shl_fr2x16 (c, -2);
  t1 = __builtin_bfin_extract_lo (d);
  t2 = __builtin_bfin_extract_hi (d);
  if ((unsigned short)t1 != 0xf000 || t2 != 0x1c00)
    abort ();

  d = __builtin_bfin_shl_fr2x16 (a, 2);
  t1 = __builtin_bfin_extract_lo (d);
  t2 = __builtin_bfin_extract_hi (d);
  if (t1 != 0x4000 || (unsigned short)t2 != 0x8014)
    abort ();

  d = __builtin_bfin_shl_fr2x16 (c, -4);
  t1 = __builtin_bfin_extract_lo (d);
  t2 = __builtin_bfin_extract_hi (d);
  if ((unsigned short)t1 != 0xfc00 || t2 != 0x0700)
    abort ();

  d = __builtin_bfin_shl_fr2x16 (c, 2);
  t1 = __builtin_bfin_extract_lo (d);
  t2 = __builtin_bfin_extract_hi (d);
  if ((unsigned short)t1 != 0x8000 || t2 != 0x7fff)
    abort ();

  d = __builtin_bfin_shl_fr2x16 (a, -2);
  t1 = __builtin_bfin_extract_lo (d);
  t2 = __builtin_bfin_extract_hi (d);
  if (t1 != 0x0400 || (unsigned short)t2 != 0xf801)
    abort ();

  /* lsh */
  d = __builtin_bfin_lshl_fr2x16 (c, -4);
  t1 = __builtin_bfin_extract_lo (d);
  t2 = __builtin_bfin_extract_hi (d);
  if (t1 != 0x0c00 || t2 != 0x0700)
    abort ();

  d = __builtin_bfin_lshl_fr2x16 (c, 2);
  t1 = __builtin_bfin_extract_lo (d);
  t2 = __builtin_bfin_extract_hi (d);
  if (t1 != 0x0000 || t2 != -0x4000)
    abort ();

  d = __builtin_bfin_lshl_fr2x16 (a, -2);
  t1 = __builtin_bfin_extract_lo (d);
  t2 = __builtin_bfin_extract_hi (d);
  if (t1 != 0x0400 || (unsigned short)t2 != 0x3801)
    abort ();

  exit (0);
}