177ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao//===-- umodsi3_test.c - Test __umodsi3 -----------------------------------===//
277ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao//
377ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao//                     The LLVM Compiler Infrastructure
477ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao//
577ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao// This file is distributed under the University of Illinois Open Source
677ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao// License. See LICENSE.TXT for details.
777ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao//
877ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao//===----------------------------------------------------------------------===//
977ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao//
1077ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao// This file tests __umodsi3 for the compiler_rt library.
1177ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao//
1277ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao//===----------------------------------------------------------------------===//
1377ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao
1477ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao#include "int_lib.h"
1577ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao#include <stdio.h>
1677ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao
1777ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao// Returns: a % b
1877ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao
1977ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liaosu_int __umodsi3(su_int a, su_int b);
2077ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao
2177ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liaoint test__umodsi3(su_int a, su_int b, su_int expected_r)
2277ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{
2377ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao    su_int r = __umodsi3(a, b);
2477ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao    if (r != expected_r)
2577ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao        printf("error in __umodsi3: %X %% %X = %X, expected %X\n",
2677ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao               a, b, r, expected_r);
2777ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao    return r != expected_r;
2877ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao}
2977ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao
3077ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liaosu_int tests[][4] =
3177ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{
3277ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000000, 0x00000001, 0x00000000},
3377ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000000, 0x00000002, 0x00000000},
3477ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000000, 0x00000003, 0x00000000},
3577ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000000, 0x00000010, 0x00000000},
3677ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000000, 0x078644FA, 0x00000000},
3777ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000000, 0x0747AE14, 0x00000000},
3877ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000000, 0x7FFFFFFF, 0x00000000},
3977ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000000, 0x80000000, 0x00000000},
4077ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000000, 0xFFFFFFFD, 0x00000000},
4177ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000000, 0xFFFFFFFE, 0x00000000},
4277ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000000, 0xFFFFFFFF, 0x00000000},
4377ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000001, 0x00000001, 0x00000000},
4477ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000001, 0x00000002, 0x00000001},
4577ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000001, 0x00000003, 0x00000001},
4677ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000001, 0x00000010, 0x00000001},
4777ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000001, 0x078644FA, 0x00000001},
4877ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000001, 0x0747AE14, 0x00000001},
4977ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000001, 0x7FFFFFFF, 0x00000001},
5077ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000001, 0x80000000, 0x00000001},
5177ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000001, 0xFFFFFFFD, 0x00000001},
5277ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000001, 0xFFFFFFFE, 0x00000001},
5377ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000001, 0xFFFFFFFF, 0x00000001},
5477ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000002, 0x00000001, 0x00000000},
5577ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000002, 0x00000002, 0x00000000},
5677ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000002, 0x00000003, 0x00000002},
5777ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000002, 0x00000010, 0x00000002},
5877ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000002, 0x078644FA, 0x00000002},
5977ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000002, 0x0747AE14, 0x00000002},
6077ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000002, 0x7FFFFFFF, 0x00000002},
6177ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000002, 0x80000000, 0x00000002},
6277ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000002, 0xFFFFFFFD, 0x00000002},
6377ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000002, 0xFFFFFFFE, 0x00000002},
6477ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000002, 0xFFFFFFFF, 0x00000002},
6577ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000003, 0x00000001, 0x00000000},
6677ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000003, 0x00000002, 0x00000001},
6777ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000003, 0x00000003, 0x00000000},
6877ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000003, 0x00000010, 0x00000003},
6977ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000003, 0x078644FA, 0x00000003},
7077ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000003, 0x0747AE14, 0x00000003},
7177ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000003, 0x7FFFFFFF, 0x00000003},
7277ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000003, 0x80000000, 0x00000003},
7377ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000003, 0xFFFFFFFD, 0x00000003},
7477ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000003, 0xFFFFFFFE, 0x00000003},
7577ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000003, 0xFFFFFFFF, 0x00000003},
7677ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000010, 0x00000001, 0x00000000},
7777ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000010, 0x00000002, 0x00000000},
7877ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000010, 0x00000003, 0x00000001},
7977ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000010, 0x00000010, 0x00000000},
8077ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000010, 0x078644FA, 0x00000010},
8177ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000010, 0x0747AE14, 0x00000010},
8277ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000010, 0x7FFFFFFF, 0x00000010},
8377ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000010, 0x80000000, 0x00000010},
8477ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000010, 0xFFFFFFFD, 0x00000010},
8577ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000010, 0xFFFFFFFE, 0x00000010},
8677ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x00000010, 0xFFFFFFFF, 0x00000010},
8777ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x078644FA, 0x00000001, 0x00000000},
8877ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x078644FA, 0x00000002, 0x00000000},
8977ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x078644FA, 0x00000003, 0x00000000},
9077ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x078644FA, 0x00000010, 0x0000000A},
9177ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x078644FA, 0x078644FA, 0x00000000},
9277ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x078644FA, 0x0747AE14, 0x003E96E6},
9377ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x078644FA, 0x7FFFFFFF, 0x078644FA},
9477ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x078644FA, 0x80000000, 0x078644FA},
9577ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x078644FA, 0xFFFFFFFD, 0x078644FA},
9677ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x078644FA, 0xFFFFFFFE, 0x078644FA},
9777ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x078644FA, 0xFFFFFFFF, 0x078644FA},
9877ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x0747AE14, 0x00000001, 0x00000000},
9977ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x0747AE14, 0x00000002, 0x00000000},
10077ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x0747AE14, 0x00000003, 0x00000002},
10177ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x0747AE14, 0x00000010, 0x00000004},
10277ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x0747AE14, 0x078644FA, 0x0747AE14},
10377ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x0747AE14, 0x0747AE14, 0x00000000},
10477ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x0747AE14, 0x7FFFFFFF, 0x0747AE14},
10577ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x0747AE14, 0x80000000, 0x0747AE14},
10677ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x0747AE14, 0xFFFFFFFD, 0x0747AE14},
10777ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x0747AE14, 0xFFFFFFFE, 0x0747AE14},
10877ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x0747AE14, 0xFFFFFFFF, 0x0747AE14},
10977ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x7FFFFFFF, 0x00000001, 0x00000000},
11077ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x7FFFFFFF, 0x00000002, 0x00000001},
11177ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x7FFFFFFF, 0x00000003, 0x00000001},
11277ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x7FFFFFFF, 0x00000010, 0x0000000F},
11377ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x7FFFFFFF, 0x078644FA, 0x00156B65},
11477ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x7FFFFFFF, 0x0747AE14, 0x043D70AB},
11577ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x7FFFFFFF, 0x7FFFFFFF, 0x00000000},
11677ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x7FFFFFFF, 0x80000000, 0x7FFFFFFF},
11777ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x7FFFFFFF, 0xFFFFFFFD, 0x7FFFFFFF},
11877ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x7FFFFFFF, 0xFFFFFFFE, 0x7FFFFFFF},
11977ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x7FFFFFFF, 0xFFFFFFFF, 0x7FFFFFFF},
12077ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x80000000, 0x00000001, 0x00000000},
12177ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x80000000, 0x00000002, 0x00000000},
12277ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x80000000, 0x00000003, 0x00000002},
12377ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x80000000, 0x00000010, 0x00000000},
12477ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x80000000, 0x078644FA, 0x00156B66},
12577ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x80000000, 0x0747AE14, 0x043D70AC},
12677ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x80000000, 0x7FFFFFFF, 0x00000001},
12777ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x80000000, 0x80000000, 0x00000000},
12877ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x80000000, 0xFFFFFFFD, 0x80000000},
12977ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x80000000, 0xFFFFFFFE, 0x80000000},
13077ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0x80000000, 0xFFFFFFFF, 0x80000000},
13177ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0xFFFFFFFD, 0x00000001, 0x00000000},
13277ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0xFFFFFFFD, 0x00000002, 0x00000001},
13377ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0xFFFFFFFD, 0x00000003, 0x00000001},
13477ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0xFFFFFFFD, 0x00000010, 0x0000000D},
13577ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0xFFFFFFFD, 0x078644FA, 0x002AD6C9},
13677ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0xFFFFFFFD, 0x0747AE14, 0x01333341},
13777ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0xFFFFFFFD, 0x7FFFFFFF, 0x7FFFFFFE},
13877ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0xFFFFFFFD, 0x80000000, 0x7FFFFFFD},
13977ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0xFFFFFFFD, 0xFFFFFFFD, 0x00000000},
14077ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0xFFFFFFFD, 0xFFFFFFFE, 0xFFFFFFFD},
14177ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0xFFFFFFFD, 0xFFFFFFFF, 0xFFFFFFFD},
14277ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0xFFFFFFFE, 0x00000001, 0x00000000},
14377ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0xFFFFFFFE, 0x00000002, 0x00000000},
14477ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0xFFFFFFFE, 0x00000003, 0x00000002},
14577ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0xFFFFFFFE, 0x00000010, 0x0000000E},
14677ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0xFFFFFFFE, 0x078644FA, 0x002AD6CA},
14777ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0xFFFFFFFE, 0x0747AE14, 0x01333342},
14877ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0xFFFFFFFE, 0x7FFFFFFF, 0x00000000},
14977ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0xFFFFFFFE, 0x80000000, 0x7FFFFFFE},
15077ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0xFFFFFFFE, 0xFFFFFFFD, 0x00000001},
15177ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0xFFFFFFFE, 0xFFFFFFFE, 0x00000000},
15277ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0xFFFFFFFE, 0xFFFFFFFF, 0xFFFFFFFE},
15377ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0xFFFFFFFF, 0x00000001, 0x00000000},
15477ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0xFFFFFFFF, 0x00000002, 0x00000001},
15577ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0xFFFFFFFF, 0x00000003, 0x00000000},
15677ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0xFFFFFFFF, 0x00000010, 0x0000000F},
15777ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0xFFFFFFFF, 0x078644FA, 0x002AD6CB},
15877ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0xFFFFFFFF, 0x0747AE14, 0x01333343},
15977ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0xFFFFFFFF, 0x7FFFFFFF, 0x00000001},
16077ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0xFFFFFFFF, 0x80000000, 0x7FFFFFFF},
16177ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0xFFFFFFFF, 0xFFFFFFFD, 0x00000002},
16277ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0xFFFFFFFF, 0xFFFFFFFE, 0x00000001},
16377ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{0xFFFFFFFF, 0xFFFFFFFF, 0x00000000}
16477ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao};
16577ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao
16677ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liaoint main()
16777ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao{
16877ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao    const unsigned N = sizeof(tests) / sizeof(tests[0]);
16977ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao    unsigned i;
17077ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao    for (i = 0; i < N; ++i)
17177ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao        if (test__umodsi3(tests[i][0], tests[i][1], tests[i][2]))
17277ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao            return 1;
17377ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao
17477ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao    return 0;
17577ed6142daed1e068fbda64405d0de9845e40e1Shih-wei Liao}
176