1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_subvsi3
3 //===-- subvsi3_test.c - Test __subvsi3 -----------------------------------===//
5 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
6 // See https://llvm.org/LICENSE.txt for license information.
7 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
9 //===----------------------------------------------------------------------===//
11 // This file tests __subvsi3 for the compiler_rt library.
13 //===----------------------------------------------------------------------===//
21 // Effects: aborts if a - b overflows
23 COMPILER_RT_ABI si_int
__subvsi3(si_int a
, si_int b
);
25 int test__subvsi3(si_int a
, si_int b
)
27 si_int x
= __subvsi3(a
, b
);
28 si_int expected
= a
- b
;
30 printf("error in test__subvsi3(0x%X, 0x%X) = %d, expected %d\n",
37 // test__subvsi3(0x80000000, 1); // should abort
38 // test__subvsi3(0, 0x80000000); // should abort
39 // test__subvsi3(1, 0x80000000); // should abort
40 // test__subvsi3(0x7FFFFFFF, -1); // should abort
41 // test__subvsi3(-2, 0x7FFFFFFF); // should abort
43 if (test__subvsi3(0x80000000, -1))
45 if (test__subvsi3(0x80000000, 0))
47 if (test__subvsi3(-1, 0x80000000))
49 if (test__subvsi3(0x7FFFFFFF, 1))
51 if (test__subvsi3(0x7FFFFFFF, 0))
53 if (test__subvsi3(1, 0x7FFFFFFF))
55 if (test__subvsi3(0, 0x7FFFFFFF))
57 if (test__subvsi3(-1, 0x7FFFFFFF))