51 lines · c
1// RUN: %clang_builtins %s %librt -o %t && %run %t2// REQUIRES: librt_has_subvsi33 4#include "int_lib.h"5#include <stdio.h>6#include <stdlib.h>7 8// Returns: a - b9 10// Effects: aborts if a - b overflows11 12COMPILER_RT_ABI si_int __subvsi3(si_int a, si_int b);13 14int test__subvsi3(si_int a, si_int b)15{16 si_int x = __subvsi3(a, b);17 si_int expected = a - b;18 if (x != expected)19 printf("error in test__subvsi3(0x%X, 0x%X) = %d, expected %d\n",20 a, b, x, expected);21 return x != expected;22}23 24int main()25{26// test__subvsi3(0x80000000, 1); // should abort27// test__subvsi3(0, 0x80000000); // should abort28// test__subvsi3(1, 0x80000000); // should abort29// test__subvsi3(0x7FFFFFFF, -1); // should abort30// test__subvsi3(-2, 0x7FFFFFFF); // should abort31 32 if (test__subvsi3(0x80000000, -1))33 return 1;34 if (test__subvsi3(0x80000000, 0))35 return 1;36 if (test__subvsi3(-1, 0x80000000))37 return 1;38 if (test__subvsi3(0x7FFFFFFF, 1))39 return 1;40 if (test__subvsi3(0x7FFFFFFF, 0))41 return 1;42 if (test__subvsi3(1, 0x7FFFFFFF))43 return 1;44 if (test__subvsi3(0, 0x7FFFFFFF))45 return 1;46 if (test__subvsi3(-1, 0x7FFFFFFF))47 return 1;48 49 return 0;50}51