brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 6b9d674 Raw
49 lines · c
1// RUN: %clang_builtins %s %librt -o %t && %run %t2// REQUIRES: librt_has_addvdi33 4#include "int_lib.h"5#include <stdio.h>6 7// Returns: a + b8 9// Effects: aborts if a + b overflows10 11COMPILER_RT_ABI di_int __addvdi3(di_int a, di_int b);12 13int test__addvdi3(di_int a, di_int b)14{15    di_int x = __addvdi3(a, b);16    di_int expected = a + b;17    if (x != expected)18        printf("error in test__addvdi3(0x%llX, 0x%llX) = %lld, expected %lld\n",19                a, b, x, expected);20    return x != expected;21}22 23int main()24{25//     test__addvdi3(0x8000000000000000LL, -1);  // should abort26//     test__addvdi3(-1, 0x8000000000000000LL);  // should abort27//     test__addvdi3(1, 0x7FFFFFFFFFFFFFFFLL);  // should abort28//     test__addvdi3(0x7FFFFFFFFFFFFFFFLL, 1);  // should abort29 30    if (test__addvdi3(0x8000000000000000LL, 1))31        return 1;32    if (test__addvdi3(1, 0x8000000000000000LL))33        return 1;34    if (test__addvdi3(0x8000000000000000LL, 0))35        return 1;36    if (test__addvdi3(0, 0x8000000000000000LL))37        return 1;38    if (test__addvdi3(0x7FFFFFFFFFFFFFFLL, -1))39        return 1;40    if (test__addvdi3(-1, 0x7FFFFFFFFFFFFFFLL))41        return 1;42    if (test__addvdi3(0x7FFFFFFFFFFFFFFFLL, 0))43        return 1;44    if (test__addvdi3(0, 0x7FFFFFFFFFFFFFFFLL))45        return 1;46 47    return 0;48}49