[libc++] Reduce std::conjunction overhead (#124259)
[llvm-project.git] / compiler-rt / test / builtins / Unit / negvdi2_test.c
blob24e72a9d2227d28f9cd43ce22abe09ebac8c719a
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_negvdi2
4 #include "int_lib.h"
5 #include <stdio.h>
7 // Returns: -a
9 // Effects: aborts if -a overflows
11 COMPILER_RT_ABI di_int __negvdi2(di_int a);
13 int test__negvdi2(di_int a)
15 di_int x = __negvdi2(a);
16 di_int expected = -a;
17 if (x != expected)
18 printf("error in __negvdi2(0x%llX) = %lld, expected %lld\n",
19 a, x, expected);
20 return x != expected;
23 int main()
25 // if (test__negvdi2(0x8000000000000000LL)) // should abort
26 // return 1;
27 if (test__negvdi2(0x0000000000000000LL))
28 return 1;
29 if (test__negvdi2(0x0000000000000001LL))
30 return 1;
31 if (test__negvdi2(0x0000000000000002LL))
32 return 1;
33 if (test__negvdi2(0x7FFFFFFFFFFFFFFELL))
34 return 1;
35 if (test__negvdi2(0x7FFFFFFFFFFFFFFFLL))
36 return 1;
37 if (test__negvdi2(0x8000000000000001LL))
38 return 1;
39 if (test__negvdi2(0x8000000000000002LL))
40 return 1;
41 if (test__negvdi2(0xFFFFFFFFFFFFFFFELL))
42 return 1;
43 if (test__negvdi2(0xFFFFFFFFFFFFFFFFLL))
44 return 1;
46 return 0;