Debian Codegraph @

gcc/testsuite/gcc.dg/signbit-5.c

raw
1 /* { dg-do run } */
2 /* { dg-options "-O3" } */
3
4 /* This test does not work when the truth type does not match vector type. */
5 /* { dg-additional-options "-march=armv8-a" { target aarch64_sve } } */
6
7
8 #include <stdint.h>
9 #include <limits.h>
10 #include <stdio.h>
11
12 #ifndef N
13 #define N 65
14 #endif
15
16 #ifndef TYPE
17 #define TYPE int32_t
18 #endif
19
20 #ifndef DEBUG
21 #define DEBUG 1
22 #endif
23
24 #define BASE ((TYPE) -1 < 0 ? -126 : 4)
25
26 __attribute__ ((noinline, noipa))
27 void fun1(TYPE *x, int n)
28 {
29 for (int i = 0; i < n; i++)
30 x[i] = (-x[i]) >> 31;
31 }
32
33 __attribute__ ((noinline, noipa, optimize("O1")))
34 void fun2(TYPE *x, int n)
35 {
36 for (int i = 0; i < n; i++)
37 x[i] = (-x[i]) >> 31;
38 }
39
40 int main ()
41 {
42 TYPE a[N];
43 TYPE b[N];
44
45 a[0] = INT_MIN+1;
46 b[0] = INT_MIN+1;
47
48 for (int i = 1; i < N; ++i)
49 {
50 a[i] = BASE + i * 13;
51 b[i] = BASE + i * 13;
52 if (DEBUG)
53 printf ("%d: 0x%x\n", i, a[i]);
54 }
55
56 fun1 (a, N);
57 fun2 (b, N);
58
59 for (int i = 0; i < N; ++i)
60 {
61 if (DEBUG)
62 printf ("%d = 0x%x == 0x%x\n", i, a[i], b[i]);
63
64 if (a[i] != b[i])
65 __builtin_abort ();
66 }
67 return 0;
68 }
69