brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1021 B · 4e27521 Raw
47 lines · c
1// RUN: %clang_builtins %s %librt -o %t && %run %t2// REQUIRES: librt_has_negvsi23 4#include "int_lib.h"5#include <stdio.h>6 7// Returns: -a8 9// Effects: aborts if -a overflows10 11COMPILER_RT_ABI si_int __negvsi2(si_int a);12 13int test__negvsi2(si_int a)14{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;20}21 22int main()23{24//     if (test__negvsi2(0x80000000))  // should abort25//         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;44 45    return 0;46}47