aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/arm/armv8_2-fp16-move-1.c
blob: 2321dd38cc6d7a3635f01180ad0f235b2a183ec2 (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
157
158
159
160
161
162
163
164
/* { dg-do compile }  */
/* { dg-require-effective-target arm_v8_2a_fp16_scalar_ok }  */
/* { dg-options "-O2" }  */
/* { dg-add-options arm_v8_2a_fp16_scalar }  */
/* { dg-additional-options "-mfloat-abi=hard" } */

__fp16
test_load_1 (__fp16* a)
{
  return *a;
}

__fp16
test_load_2 (__fp16* a, int i)
{
  return a[i];
}


void
test_store_1 (__fp16* a, __fp16 b)
{
  *a = b;
}

void
test_store_2 (__fp16* a, int i, __fp16 b)
{
  a[i] = b;
}


__fp16
test_load_store_1 (__fp16* a, int i, __fp16* b)
{
  a[i] = b[i];
}

__fp16
test_load_store_2 (__fp16* a, int i, __fp16* b)
{
  a[i] = b[i + 2];
  return a[i];
}

/* { dg-final { scan-assembler-times {vst1\.16\t\{d[0-9]+\[[0-9]+\]\}, \[r[0-9]+\]} 3 } }  */
/* { dg-final { scan-assembler-times {vld1\.16\t\{d[0-9]+\[[0-9]+\]\}, \[r[0-9]+\]} 3 } }  */

__fp16
test_select_1 (int sel, __fp16 a, __fp16 b)
{
  if (sel)
    return a;
  else
    return b;
}

__fp16
test_select_2 (int sel, __fp16 a, __fp16 b)
{
  return sel ? a : b;
}

__fp16
test_select_3 (__fp16 a, __fp16 b, __fp16 c)
{
  return (a == b) ? b : c;
}

__fp16
test_select_4 (__fp16 a, __fp16 b, __fp16 c)
{
  return (a != b) ? b : c;
}

__fp16
test_select_5 (__fp16 a, __fp16 b, __fp16 c)
{
  return (a < b) ? b : c;
}

__fp16
test_select_6 (__fp16 a, __fp16 b, __fp16 c)
{
  return (a <= b) ? b : c;
}

__fp16
test_select_7 (__fp16 a, __fp16 b, __fp16 c)
{
  return (a > b) ? b : c;
}

__fp16
test_select_8 (__fp16 a, __fp16 b, __fp16 c)
{
  return (a >= b) ? b : c;
}

/* { dg-final { scan-assembler-times {vseleq\.f16\ts[0-9]+, s[0-9]+, s[0-9]+} 4 } } */
/* { dg-final { scan-assembler-times {vselgt\.f16\ts[0-9]+, s[0-9]+, s[0-9]+} 1 } }  */
/* { dg-final { scan-assembler-times {vselge\.f16\ts[0-9]+, s[0-9]+, s[0-9]+} 1 } }  */

/* { dg-final { scan-assembler-not {vmov\.f16} } }  */

int
test_compare_1 (__fp16 a, __fp16 b)
{
  if (a == b)
    return -1;
  else
    return 0;
}

int
test_compare_ (__fp16 a, __fp16 b)
{
  if (a != b)
    return -1;
  else
    return 0;
}

int
test_compare_2 (__fp16 a, __fp16 b)
{
  if (a > b)
    return -1;
  else
    return 0;
}

int
test_compare_3 (__fp16 a, __fp16 b)
{
  if (a >= b)
    return -1;
  else
    return 0;
}

int
test_compare_4 (__fp16 a, __fp16 b)
{
  if (a < b)
    return -1;
  else
    return 0;
}

int
test_compare_5 (__fp16 a, __fp16 b)
{
  if (a <= b)
    return -1;
  else
    return 0;
}

/* { dg-final { scan-assembler-not {vcmp\.f16} } }  */
/* { dg-final { scan-assembler-not {vcmpe\.f16} } }  */

/* { dg-final { scan-assembler-times {vcmp\.f32} 4 } }  */
/* { dg-final { scan-assembler-times {vcmpe\.f32} 8 } }  */