1 /* Check that the compiler does not optimise the negation out.
2 We need to check for this because there is a mismatch in semantics
3 between the ACLE, which states that he negative of the minimum
4 (signed) value is itself and C, where this is undefined behaviour. */
5
6 /* { dg-do run } */
7 /* { dg-options "--save-temps -O2" } */
8
9 #include <arm_neon.h>
10 #include <limits.h>
11
12 extern void abort (void);
13
14 int
15 foo (int64_t x)
16 {
17 if (x < (int64_t) 0)
18 return vnegd_s64 (x) < (int64_t) 0;
19 else
20 return -1;
21 }
22
23 /* { dg-final { scan-assembler-times {neg\tx[0-9]+, x[0-9]+} 1 } } */
24
25 int
26 main (void)
27 {
28 int ans = 1;
29 int res = foo (INT64_MIN);
30
31 if (res != ans)
32 abort ();
33
34 return 0;
35 }
36