[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / compiler-rt / test / builtins / Unit / riscv / mulsi3_test.c
blob3496b2da7eda2c7cc90b3ce8325d64a95c236245
1 // REQUIRES: riscv32-target-arch
2 // RUN: %clang_builtins %s %librt -o %t && %run %t
3 //===-- mulsi3_test.c - Test __mulsi3 -------------------------------------===//
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 __mulsi3 for the compiler_rt library.
13 //===----------------------------------------------------------------------===//
15 #include "int_lib.h"
16 #include <stdio.h>
17 #include <limits.h>
19 #if !defined(__riscv_mul) && __riscv_xlen == 32
20 // Based on mulsi3_test.c
22 COMPILER_RT_ABI si_int __mulsi3(si_int a, si_int b);
24 int test__mulsi3(si_int a, si_int b, si_int expected)
26 si_int x = __mulsi3(a, b);
27 if (x != expected)
28 printf("error in __mulsi3: %d * %d = %d, expected %d\n",
29 a, b, __mulsi3(a, b), expected);
30 return x != expected;
32 #endif
34 int main()
36 #if !defined(__riscv_mul) && __riscv_xlen == 32
37 if (test__mulsi3(0, 0, 0))
38 return 1;
39 if (test__mulsi3(0, 1, 0))
40 return 1;
41 if (test__mulsi3(1, 0, 0))
42 return 1;
43 if (test__mulsi3(0, 10, 0))
44 return 1;
45 if (test__mulsi3(10, 0, 0))
46 return 1;
47 if (test__mulsi3(0, INT_MAX, 0))
48 return 1;
49 if (test__mulsi3(INT_MAX, 0, 0))
50 return 1;
52 if (test__mulsi3(0, -1, 0))
53 return 1;
54 if (test__mulsi3(-1, 0, 0))
55 return 1;
56 if (test__mulsi3(0, -10, 0))
57 return 1;
58 if (test__mulsi3(-10, 0, 0))
59 return 1;
60 if (test__mulsi3(0, INT_MIN, 0))
61 return 1;
62 if (test__mulsi3(INT_MIN, 0, 0))
63 return 1;
65 if (test__mulsi3(1, 1, 1))
66 return 1;
67 if (test__mulsi3(1, 10, 10))
68 return 1;
69 if (test__mulsi3(10, 1, 10))
70 return 1;
71 if (test__mulsi3(1, INT_MAX, INT_MAX))
72 return 1;
73 if (test__mulsi3(INT_MAX, 1, INT_MAX))
74 return 1;
76 if (test__mulsi3(1, -1, -1))
77 return 1;
78 if (test__mulsi3(1, -10, -10))
79 return 1;
80 if (test__mulsi3(-10, 1, -10))
81 return 1;
82 if (test__mulsi3(1, INT_MIN, INT_MIN))
83 return 1;
84 if (test__mulsi3(INT_MIN, 1, INT_MIN))
85 return 1;
87 if (test__mulsi3(46340, 46340, 2147395600))
88 return 1;
89 if (test__mulsi3(-46340, 46340, -2147395600))
90 return 1;
91 if (test__mulsi3(46340, -46340, -2147395600))
92 return 1;
93 if (test__mulsi3(-46340, -46340, 2147395600))
94 return 1;
96 if (test__mulsi3(4194303, 8192, 34359730176))
97 return 1;
98 if (test__mulsi3(-4194303, 8192, -34359730176))
99 return 1;
100 if (test__mulsi3(4194303, -8192, -34359730176))
101 return 1;
102 if (test__mulsi3(-4194303, -8192, 34359730176))
103 return 1;
105 if (test__mulsi3(8192, 4194303, 34359730176))
106 return 1;
107 if (test__mulsi3(-8192, 4194303, -34359730176))
108 return 1;
109 if (test__mulsi3(8192, -4194303, -34359730176))
110 return 1;
111 if (test__mulsi3(-8192, -4194303, 34359730176))
112 return 1;
113 #else
114 printf("skipped\n");
115 #endif
117 return 0;