1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_addvdi3
3 //===-- addvdi3_test.c - Test __addvdi3 -----------------------------------===//
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 __addvdi3 for the compiler_rt library.
13 //===----------------------------------------------------------------------===//
20 // Effects: aborts if a + b overflows
22 COMPILER_RT_ABI di_int
__addvdi3(di_int a
, di_int b
);
24 int test__addvdi3(di_int a
, di_int b
)
26 di_int x
= __addvdi3(a
, b
);
27 di_int expected
= a
+ b
;
29 printf("error in test__addvdi3(0x%llX, 0x%llX) = %lld, expected %lld\n",
36 // test__addvdi3(0x8000000000000000LL, -1); // should abort
37 // test__addvdi3(-1, 0x8000000000000000LL); // should abort
38 // test__addvdi3(1, 0x7FFFFFFFFFFFFFFFLL); // should abort
39 // test__addvdi3(0x7FFFFFFFFFFFFFFFLL, 1); // should abort
41 if (test__addvdi3(0x8000000000000000LL
, 1))
43 if (test__addvdi3(1, 0x8000000000000000LL
))
45 if (test__addvdi3(0x8000000000000000LL
, 0))
47 if (test__addvdi3(0, 0x8000000000000000LL
))
49 if (test__addvdi3(0x7FFFFFFFFFFFFFFLL
, -1))
51 if (test__addvdi3(-1, 0x7FFFFFFFFFFFFFFLL
))
53 if (test__addvdi3(0x7FFFFFFFFFFFFFFFLL
, 0))
55 if (test__addvdi3(0, 0x7FFFFFFFFFFFFFFFLL
))