[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / compiler-rt / test / builtins / Unit / modsi3_test.c
blob538a31b5aa401e52421f27fd81ab309b0e46762e
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_modsi3
3 /* ===-- modsi3_test.c - Test __modsi3 -------------------------------------===
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 __modsi3 for the compiler_rt library.
13 * ===----------------------------------------------------------------------===
16 #include "int_lib.h"
17 #include <stdio.h>
19 /* Returns: a % b */
21 COMPILER_RT_ABI si_int __modsi3(si_int a, si_int b);
23 int test__modsi3(si_int a, si_int b, si_int expected) {
24 si_int x = __modsi3(a, b);
25 if (x != expected)
26 fprintf(stderr, "error in __modsi3: %d %% %d = %d, expected %d\n",
27 a, b, x, expected);
28 return x != expected;
31 int main() {
32 if (test__modsi3(0, 1, 0))
33 return 1;
34 if (test__modsi3(0, -1, 0))
35 return 1;
37 if (test__modsi3(5, 3, 2))
38 return 1;
39 if (test__modsi3(5, -3, 2))
40 return 1;
41 if (test__modsi3(-5, 3, -2))
42 return 1;
43 if (test__modsi3(-5, -3, -2))
44 return 1;
46 if (test__modsi3(0x80000000, 1, 0x0))
47 return 1;
48 if (test__modsi3(0x80000000, 2, 0x0))
49 return 1;
50 if (test__modsi3(0x80000000, -2, 0x0))
51 return 1;
52 if (test__modsi3(0x80000000, 3, -2))
53 return 1;
54 if (test__modsi3(0x80000000, -3, -2))
55 return 1;
57 return 0;