blob: 6330803d5fcf0a5e17740578225fa8a69e5514e3 [file] [log] [blame]
Daniel Dunbarfd089992009-06-26 16:47:03 +00001//===-- negvsi2_test.c - Test __negvsi2 -----------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Howard Hinnant5b791f62010-11-16 22:13:33 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Daniel Dunbarfd089992009-06-26 16:47:03 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file tests __negvsi2 for the compiler_rt library.
11//
12//===----------------------------------------------------------------------===//
13
14#include "int_lib.h"
15#include <stdio.h>
16
17// Returns: -a
18
19// Effects: aborts if -a overflows
20
Derek Schuffeb0ebc32015-04-24 15:45:57 +000021COMPILER_RT_ABI si_int __negvsi2(si_int a);
Daniel Dunbarfd089992009-06-26 16:47:03 +000022
23int test__negvsi2(si_int a)
24{
25 si_int x = __negvsi2(a);
26 si_int expected = -a;
27 if (x != expected)
28 printf("error in __negvsi2(0x%X) = %d, expected %d\n", a, x, expected);
29 return x != expected;
30}
31
32int main()
33{
34// if (test__negvsi2(0x80000000)) // should abort
35// return 1;
36 if (test__negvsi2(0x00000000))
37 return 1;
38 if (test__negvsi2(0x00000001))
39 return 1;
40 if (test__negvsi2(0x00000002))
41 return 1;
42 if (test__negvsi2(0x7FFFFFFE))
43 return 1;
44 if (test__negvsi2(0x7FFFFFFF))
45 return 1;
46 if (test__negvsi2(0x80000001))
47 return 1;
48 if (test__negvsi2(0x80000002))
49 return 1;
50 if (test__negvsi2(0xFFFFFFFE))
51 return 1;
52 if (test__negvsi2(0xFFFFFFFF))
53 return 1;
54
55 return 0;
56}