1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_muldi3
3 //===-- muldi3_test.c - Test __muldi3 -------------------------------------===//
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 __muldi3 for the compiler_rt library.
13 //===----------------------------------------------------------------------===//
18 COMPILER_RT_ABI di_int
__muldi3(di_int a
, di_int b
);
20 int test__muldi3(di_int a
, di_int b
, di_int expected
)
22 di_int x
= __muldi3(a
, b
);
24 printf("error in __muldi3: %lld * %lld = %lld, expected %lld\n",
25 a
, b
, __muldi3(a
, b
), expected
);
29 char assumption_1
[sizeof(di_int
) == 2*sizeof(si_int
)] = {0};
33 if (test__muldi3(0, 0, 0))
35 if (test__muldi3(0, 1, 0))
37 if (test__muldi3(1, 0, 0))
39 if (test__muldi3(0, 10, 0))
41 if (test__muldi3(10, 0, 0))
43 if (test__muldi3(0, 81985529216486895LL, 0))
45 if (test__muldi3(81985529216486895LL, 0, 0))
48 if (test__muldi3(0, -1, 0))
50 if (test__muldi3(-1, 0, 0))
52 if (test__muldi3(0, -10, 0))
54 if (test__muldi3(-10, 0, 0))
56 if (test__muldi3(0, -81985529216486895LL, 0))
58 if (test__muldi3(-81985529216486895LL, 0, 0))
61 if (test__muldi3(1, 1, 1))
63 if (test__muldi3(1, 10, 10))
65 if (test__muldi3(10, 1, 10))
67 if (test__muldi3(1, 81985529216486895LL, 81985529216486895LL))
69 if (test__muldi3(81985529216486895LL, 1, 81985529216486895LL))
72 if (test__muldi3(1, -1, -1))
74 if (test__muldi3(1, -10, -10))
76 if (test__muldi3(-10, 1, -10))
78 if (test__muldi3(1, -81985529216486895LL, -81985529216486895LL))
80 if (test__muldi3(-81985529216486895LL, 1, -81985529216486895LL))
83 if (test__muldi3(3037000499LL, 3037000499LL, 9223372030926249001LL))
85 if (test__muldi3(-3037000499LL, 3037000499LL, -9223372030926249001LL))
87 if (test__muldi3(3037000499LL, -3037000499LL, -9223372030926249001LL))
89 if (test__muldi3(-3037000499LL, -3037000499LL, 9223372030926249001LL))
92 if (test__muldi3(4398046511103LL, 2097152LL, 9223372036852678656LL))
94 if (test__muldi3(-4398046511103LL, 2097152LL, -9223372036852678656LL))
96 if (test__muldi3(4398046511103LL, -2097152LL, -9223372036852678656LL))
98 if (test__muldi3(-4398046511103LL, -2097152LL, 9223372036852678656LL))
101 if (test__muldi3(2097152LL, 4398046511103LL, 9223372036852678656LL))
103 if (test__muldi3(-2097152LL, 4398046511103LL, -9223372036852678656LL))
105 if (test__muldi3(2097152LL, -4398046511103LL, -9223372036852678656LL))
107 if (test__muldi3(-2097152LL, -4398046511103LL, 9223372036852678656LL))