[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / compiler-rt / test / builtins / Unit / muldi3_test.c
blobbb79149c065c9d2695545986de5b2c5d1202d5bf
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_muldi3
3 //===-- muldi3_test.c - Test __muldi3 -------------------------------------===//
4 //
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
8 //
9 //===----------------------------------------------------------------------===//
11 // This file tests __muldi3 for the compiler_rt library.
13 //===----------------------------------------------------------------------===//
15 #include "int_lib.h"
16 #include <stdio.h>
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);
23 if (x != expected)
24 printf("error in __muldi3: %lld * %lld = %lld, expected %lld\n",
25 a, b, __muldi3(a, b), expected);
26 return x != expected;
29 char assumption_1[sizeof(di_int) == 2*sizeof(si_int)] = {0};
31 int main()
33 if (test__muldi3(0, 0, 0))
34 return 1;
35 if (test__muldi3(0, 1, 0))
36 return 1;
37 if (test__muldi3(1, 0, 0))
38 return 1;
39 if (test__muldi3(0, 10, 0))
40 return 1;
41 if (test__muldi3(10, 0, 0))
42 return 1;
43 if (test__muldi3(0, 81985529216486895LL, 0))
44 return 1;
45 if (test__muldi3(81985529216486895LL, 0, 0))
46 return 1;
48 if (test__muldi3(0, -1, 0))
49 return 1;
50 if (test__muldi3(-1, 0, 0))
51 return 1;
52 if (test__muldi3(0, -10, 0))
53 return 1;
54 if (test__muldi3(-10, 0, 0))
55 return 1;
56 if (test__muldi3(0, -81985529216486895LL, 0))
57 return 1;
58 if (test__muldi3(-81985529216486895LL, 0, 0))
59 return 1;
61 if (test__muldi3(1, 1, 1))
62 return 1;
63 if (test__muldi3(1, 10, 10))
64 return 1;
65 if (test__muldi3(10, 1, 10))
66 return 1;
67 if (test__muldi3(1, 81985529216486895LL, 81985529216486895LL))
68 return 1;
69 if (test__muldi3(81985529216486895LL, 1, 81985529216486895LL))
70 return 1;
72 if (test__muldi3(1, -1, -1))
73 return 1;
74 if (test__muldi3(1, -10, -10))
75 return 1;
76 if (test__muldi3(-10, 1, -10))
77 return 1;
78 if (test__muldi3(1, -81985529216486895LL, -81985529216486895LL))
79 return 1;
80 if (test__muldi3(-81985529216486895LL, 1, -81985529216486895LL))
81 return 1;
83 if (test__muldi3(3037000499LL, 3037000499LL, 9223372030926249001LL))
84 return 1;
85 if (test__muldi3(-3037000499LL, 3037000499LL, -9223372030926249001LL))
86 return 1;
87 if (test__muldi3(3037000499LL, -3037000499LL, -9223372030926249001LL))
88 return 1;
89 if (test__muldi3(-3037000499LL, -3037000499LL, 9223372030926249001LL))
90 return 1;
92 if (test__muldi3(4398046511103LL, 2097152LL, 9223372036852678656LL))
93 return 1;
94 if (test__muldi3(-4398046511103LL, 2097152LL, -9223372036852678656LL))
95 return 1;
96 if (test__muldi3(4398046511103LL, -2097152LL, -9223372036852678656LL))
97 return 1;
98 if (test__muldi3(-4398046511103LL, -2097152LL, 9223372036852678656LL))
99 return 1;
101 if (test__muldi3(2097152LL, 4398046511103LL, 9223372036852678656LL))
102 return 1;
103 if (test__muldi3(-2097152LL, 4398046511103LL, -9223372036852678656LL))
104 return 1;
105 if (test__muldi3(2097152LL, -4398046511103LL, -9223372036852678656LL))
106 return 1;
107 if (test__muldi3(-2097152LL, -4398046511103LL, 9223372036852678656LL))
108 return 1;
110 return 0;