1 //===-- negvsi2_test.c - Test __negvsi2 -----------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 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 21 si_int __negvsi2(si_int a); 22 test__negvsi2(si_int a)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 main()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 } 57