Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / builtins / Unit / negvsi2_test.c
blob4e275210664bfdfd844cb18bc177b2a79c8cbdb6
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_negvsi2
4 #include "int_lib.h"
5 #include <stdio.h>
7 // Returns: -a
9 // Effects: aborts if -a overflows
11 COMPILER_RT_ABI si_int __negvsi2(si_int a);
13 int test__negvsi2(si_int a)
15 si_int x = __negvsi2(a);
16 si_int expected = -a;
17 if (x != expected)
18 printf("error in __negvsi2(0x%X) = %d, expected %d\n", a, x, expected);
19 return x != expected;
22 int main()
24 // if (test__negvsi2(0x80000000)) // should abort
25 // return 1;
26 if (test__negvsi2(0x00000000))
27 return 1;
28 if (test__negvsi2(0x00000001))
29 return 1;
30 if (test__negvsi2(0x00000002))
31 return 1;
32 if (test__negvsi2(0x7FFFFFFE))
33 return 1;
34 if (test__negvsi2(0x7FFFFFFF))
35 return 1;
36 if (test__negvsi2(0x80000001))
37 return 1;
38 if (test__negvsi2(0x80000002))
39 return 1;
40 if (test__negvsi2(0xFFFFFFFE))
41 return 1;
42 if (test__negvsi2(0xFFFFFFFF))
43 return 1;
45 return 0;