Debian Codegraph @

gcc/testsuite/gcc.target/i386/part-vect-xorsignhf.c

raw
1 /* { dg-do run { target avx512fp16 } } */
2 /* { dg-options "-O1 -mavx512fp16 -mavx512vl -ftree-vectorize -fdump-tree-slp-details -fdump-tree-optimized" } */
3
4 extern void abort ();
5
6 static void do_test (void);
7
8 #define DO_TEST do_test
9 #define AVX512FP16
10 #include "avx512-check.h"
11
12 #define N 16
13 _Float16 a[N] = {-0.1f, -3.2f, -6.3f, -9.4f,
14 -12.5f, -15.6f, -18.7f, -21.8f,
15 24.9f, 27.1f, 30.2f, 33.3f,
16 36.4f, 39.5f, 42.6f, 45.7f};
17 _Float16 b[N] = {-1.2f, 3.4f, -5.6f, 7.8f,
18 -9.0f, 1.0f, -2.0f, 3.0f,
19 -4.0f, -5.0f, 6.0f, 7.0f,
20 -8.0f, -9.0f, 10.0f, 11.0f};
21 _Float16 r[N];
22
23 void
24 __attribute__((noipa,noinline,optimize("O2")))
25 xorsign_32 (void)
26 {
27 r[0] = a[0] * __builtin_copysignf16 (1.0f, b[0]);
28 r[1] = a[1] * __builtin_copysignf16 (1.0f, b[1]);
29 }
30
31 void
32 __attribute__((noipa,noinline,optimize("O2")))
33 xorsign_64 (void)
34 {
35 r[0] = a[0] * __builtin_copysignf16 (1.0f, b[0]);
36 r[1] = a[1] * __builtin_copysignf16 (1.0f, b[1]);
37 r[2] = a[2] * __builtin_copysignf16 (1.0f, b[2]);
38 r[3] = a[3] * __builtin_copysignf16 (1.0f, b[3]);
39 }
40
41 static void
42 __attribute__ ((noinline, noclone))
43 do_test (void)
44 {
45 xorsign_32 ();
46 /* check results: */
47 for (int i = 0; i != 2; i++)
48 if (r[i] != a[i] * __builtin_copysignf16 (1.0f, b[i]))
49 abort ();
50
51 xorsign_64 ();
52 /* check results: */
53 for (int i = 0; i != 4; i++)
54 if (r[i] != a[i] * __builtin_copysignf16 (1.0f, b[i]))
55 abort ();
56 }
57
58 /* { dg-final { scan-tree-dump-times "vectorized using 8 byte vectors" 1 "slp2" } } */
59 /* { dg-final { scan-tree-dump-times "vectorized using 4 byte vectors" 1 "slp2" } } */
60 /* { dg-final { scan-tree-dump-times ".XORSIGN" 2 "optimized" { target { ! ia32 } } } } */