aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.target/aarch64/tst_2.c
blob: 1e8090464bff634a3d94527f997aa44811db9660 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/* { dg-do run } */
/* { dg-options "-O2 --save-temps -fno-inline" } */

extern void abort (void);

int
tst_si_test1 (int a, int b, int c)
{
  int d = a & b;

  /* { dg-final { scan-assembler-not "tst\tw\[0-9\]+, w\[0-9\]+, w\[0-9\]+" } } */
  /* { dg-final { scan-assembler-times "and\tw\[0-9\]+, w\[0-9\]+, w\[0-9\]+" 2 } } */
  if (d <= 0)
    return 12;
  else
    return 18;
}

int
tst_si_test2 (int a, int b, int c)
{
  int d = a & 0x99999999;

  /* { dg-final { scan-assembler-not "tst\tw\[0-9\]+, w\[0-9\]+, -1717986919" } } */
  /* { dg-final { scan-assembler "and\tw\[0-9\]+, w\[0-9\]+, -1717986919" } } */
  if (d <= 0)
    return 12;
  else
    return 18;
}

int
tst_si_test3 (int a, int b, int c)
{
  int d = a & (b << 3);

  /* { dg-final { scan-assembler-not "tst\tw\[0-9\]+, w\[0-9\]+, w\[0-9\]+, lsl 3" } } */
  /* { dg-final { scan-assembler "and\tw\[0-9\]+, w\[0-9\]+, w\[0-9\]+, lsl 3" } } */
  if (d <= 0)
    return 12;
  else
    return 18;
}

typedef long long s64;

s64
tst_di_test1 (s64 a, s64 b, s64 c)
{
  s64 d = a & b;

  /* { dg-final { scan-assembler-not "tst\tx\[0-9\]+, x\[0-9\]+, x\[0-9\]+" } } */
  /* { dg-final { scan-assembler-times "and\tx\[0-9\]+, x\[0-9\]+, x\[0-9\]+" 2 } } */
  if (d <= 0)
    return 12;
  else
    return 18;
}

s64
tst_di_test2 (s64 a, s64 b, s64 c)
{
  s64 d = a & 0xaaaaaaaaaaaaaaaall;

  /* { dg-final { scan-assembler-not "tst\tx\[0-9\]+, x\[0-9\]+, -6148914691236517206" } } */
  /* { dg-final { scan-assembler "and\tx\[0-9\]+, x\[0-9\]+, -6148914691236517206" } } */
  if (d <= 0)
    return 12;
  else
    return 18;
}

s64
tst_di_test3 (s64 a, s64 b, s64 c)
{
  s64 d = a & (b << 3);

  /* { dg-final { scan-assembler-not "tst\tx\[0-9\]+, x\[0-9\]+, x\[0-9\]+, lsl 3" } } */
  /* { dg-final { scan-assembler "and\tx\[0-9\]+, x\[0-9\]+, x\[0-9\]+, lsl 3" } } */
  if (d <= 0)
    return 12;
  else
    return 18;
}

int
main ()
{
  int x;
  s64 y;

  x = tst_si_test1 (29, 4, 5);
  if (x != 18)
    abort ();

  x = tst_si_test1 (5, 2, 20);
  if (x != 12)
    abort ();

  x = tst_si_test2 (29, 4, 5);
  if (x != 18)
    abort ();

  x = tst_si_test2 (1024, 2, 20);
  if (x != 12)
    abort ();

  x = tst_si_test3 (35, 4, 5);
  if (x != 18)
    abort ();

  x = tst_si_test3 (5, 2, 20);
  if (x != 12)
    abort ();

  y = tst_di_test1 (0x130000029ll,
                     0x320000004ll,
                     0x505050505ll);

  if (y != 18)
    abort ();

  y = tst_di_test1 (0x5000500050005ll,
                     0x2111211121112ll,
                     0x0000000002020ll);
  if (y != 12)
    abort ();

  y = tst_di_test2 (0x130000029ll,
                     0x320000004ll,
                     0x505050505ll);
  if (y != 18)
    abort ();

  y = tst_di_test2 (0x540004100ll,
                     0x320000004ll,
                     0x805050205ll);
  if (y != 12)
    abort ();

  y = tst_di_test3 (0x130000029ll,
                     0x064000008ll,
                     0x505050505ll);
  if (y != 18)
    abort ();

  y = tst_di_test3 (0x130002900ll,
                     0x088000008ll,
                     0x505050505ll);
  if (y != 12)
    abort ();

  return 0;
}

/* { dg-final { cleanup-saved-temps } } */