]> git.proxmox.com Git - rustc.git/blame - src/libcompiler_builtins/compiler-rt/test/builtins/Unit/negvsi2_test.c
New upstream version 1.28.0+dfsg1
[rustc.git] / src / libcompiler_builtins / compiler-rt / test / builtins / Unit / negvsi2_test.c
CommitLineData
2c00a5a8 1// RUN: %clang_builtins %s %librt -o %t && %run %t
1a4d82fc
JJ
2//===-- negvsi2_test.c - Test __negvsi2 -----------------------------------===//
3//
4// The LLVM Compiler Infrastructure
5//
6// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
8//
9//===----------------------------------------------------------------------===//
10//
11// This file tests __negvsi2 for the compiler_rt library.
12//
13//===----------------------------------------------------------------------===//
14
15#include "int_lib.h"
16#include <stdio.h>
17
18// Returns: -a
19
20// Effects: aborts if -a overflows
21
92a42be0 22COMPILER_RT_ABI si_int __negvsi2(si_int a);
1a4d82fc
JJ
23
24int test__negvsi2(si_int a)
25{
26 si_int x = __negvsi2(a);
27 si_int expected = -a;
28 if (x != expected)
29 printf("error in __negvsi2(0x%X) = %d, expected %d\n", a, x, expected);
30 return x != expected;
31}
32
33int main()
34{
35// if (test__negvsi2(0x80000000)) // should abort
36// return 1;
37 if (test__negvsi2(0x00000000))
38 return 1;
39 if (test__negvsi2(0x00000001))
40 return 1;
41 if (test__negvsi2(0x00000002))
42 return 1;
43 if (test__negvsi2(0x7FFFFFFE))
44 return 1;
45 if (test__negvsi2(0x7FFFFFFF))
46 return 1;
47 if (test__negvsi2(0x80000001))
48 return 1;
49 if (test__negvsi2(0x80000002))
50 return 1;
51 if (test__negvsi2(0xFFFFFFFE))
52 return 1;
53 if (test__negvsi2(0xFFFFFFFF))
54 return 1;
55
56 return 0;
57}