Debian Codegraph @

gcc/testsuite/gcc.dg/vect/vect-mulhrs-1.c

raw
1 /* { dg-require-effective-target vect_int } */
2
3 #include "tree-vect.h"
4 #ifndef SIGNEDNESS
5 #define SIGNEDNESS signed
6 #endif
7 #ifndef BIAS
8 #define BIAS 0
9 #endif
10
11 #define HRS(x) ((((x) >> (15 - BIAS)) + BIAS) >> BIAS)
12
13 void __attribute__ ((noipa))
14 f (SIGNEDNESS short *restrict a, SIGNEDNESS short *restrict b,
15 SIGNEDNESS short *restrict c, __INTPTR_TYPE__ n)
16 {
17 for (__INTPTR_TYPE__ i = 0; i < n; ++i)
18 a[i] = HRS((SIGNEDNESS int) b[i] * (SIGNEDNESS int) c[i]);
19 }
20
21 #define N 50
22 #define BASE1 ((SIGNEDNESS int) -1 < 0 ? -126 : 4)
23 #define BASE2 ((SIGNEDNESS int) -1 < 0 ? -101 : 26)
24 #define CONST1 0x01AB
25 #define CONST2 0x01CD
26
27 int
28 main (void)
29 {
30 check_vect ();
31
32 SIGNEDNESS short a[N], b[N], c[N];
33 for (int i = 0; i < N; ++i)
34 {
35 b[i] = BASE1 + i * CONST1;
36 c[i] = BASE2 + i * CONST2;
37 asm volatile ("" ::: "memory");
38 }
39 f (a, b, c, N);
40 #pragma GCC novector
41 for (int i = 0; i < N; ++i)
42 if (a[i] != HRS(BASE1 * BASE2 + i * i * (CONST1 * CONST2)
43 + i * (BASE1 * CONST2 + BASE2 * CONST1)))
44 __builtin_abort ();
45 return 0;
46 }
47
48 /* { dg-final { scan-tree-dump "vect_recog_mulhs_pattern: detected" "vect" } } */
49 /* { dg-final { scan-tree-dump {\.MULHS} "vect" { target vect_mulhrs_hi } } } */
50 /* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_mulhrs_hi } } } */