Initialize libbullet git in 2.0_beta.
[platform/upstream/libbullet.git] / Extras / simdmathlibrary / spu / tests / lldivu2.c
1 /* Test lldivu2 for SPU
2    Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
3    All rights reserved.
4
5    Redistribution and use in source and binary forms,
6    with or without modification, are permitted provided that the
7    following conditions are met:
8     * Redistributions of source code must retain the above copyright
9       notice, this list of conditions and the following disclaimer.
10     * Redistributions in binary form must reproduce the above copyright
11       notice, this list of conditions and the following disclaimer in the
12       documentation and/or other materials provided with the distribution.
13     * Neither the name of the Sony Computer Entertainment Inc nor the names
14       of its contributors may be used to endorse or promote products derived
15       from this software without specific prior written permission.
16
17    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20    ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21    LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27    POSSIBILITY OF SUCH DAMAGE.
28  */
29
30
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <math.h>
34 #include "simdmath.h"
35 #include "common-test.h"
36 #include "testutils.h"
37
38 int main()
39 {
40    TEST_SET_START("20060904200000MH","MH", "lldivu2");
41
42    unsigned long long x0n = 0x0c0e84c75f216c43ull;
43    unsigned long long x0d = 0x00000000000abcdeull;
44    unsigned long long x0q = 0x0000011f71fb04cbull;
45    unsigned long long x0r = 0x0000000000003039ull;
46    unsigned long long x1n = 0x0c0e84c75f216c43ull;
47    unsigned long long x1d = 0x0000011f71fb04cbull;
48    unsigned long long x1q = 0x00000000000abcdeull;
49    unsigned long long x1r = 0x0000000000003039ull;
50
51    unsigned long long x2n = 0x08e732f9d4baf903ull;
52    unsigned long long x2d = 0x0000000000976bb6ull;
53    unsigned long long x2q = 0x0000000f0d55f4d9ull;
54    unsigned long long x2r = 0x00000000004933bdull;
55    unsigned long long x3n = 0x08e732f9d4baf903ull;
56    unsigned long long x3d = 0x0000000f0d55f4d9ull;
57    unsigned long long x3q = 0x0000000000976bb6ull;
58    unsigned long long x3r = 0x00000000004933bdull;
59
60    unsigned long long x4n = 0xffffffffffffffffull;
61    unsigned long long x4d = 0xfffffffffffffffeull;
62    unsigned long long x4q = 0x0000000000000001ull;
63    unsigned long long x4r = 0x0000000000000001ull;
64    unsigned long long x5n = 0xffffffffffffffffull;
65    unsigned long long x5d = 0x0000000000000001ull;
66    unsigned long long x5q = 0xffffffffffffffffull;
67    unsigned long long x5r = 0x0000000000000000ull;
68
69    unsigned long long x6n = 0xffffffffffffffffull;
70    unsigned long long x6d = 0x0000000000000002ull;
71    unsigned long long x6q = 0x7fffffffffffffffull;
72    unsigned long long x6r = 0x0000000000000001ull;
73    unsigned long long x7n = 0xffffffffffffffffull;
74    unsigned long long x7d = 0x7fffffffffffffffull;
75    unsigned long long x7q = 0x0000000000000002ull;
76    unsigned long long x7r = 0x0000000000000001ull;
77
78    unsigned long long x8n = 0xf8c0d45d0ff344f0ull;
79    unsigned long long x8d = 0x000019aa3e41e0bdull;
80    unsigned long long x8q = 0x000000000009b13bull;
81    unsigned long long x8r = 0x000004c443bccc61ull;
82    unsigned long long x9n = 0xf8c0d45d0ff344f0ull;
83    unsigned long long x9d = 0x000000000009b13bull;
84    unsigned long long x9q = 0x000019aa3ebfc739ull;
85    unsigned long long x9r = 0x000000000000f1cdull;
86
87    vec_ullong2 x0n_v = (vec_ullong2){ x0n, x1n };
88    vec_ullong2 x0d_v = (vec_ullong2){ x0d, x1d };
89    vec_ullong2 x0q_v = (vec_ullong2){ x0q, x1q };
90    vec_ullong2 x0r_v = (vec_ullong2){ x0r, x1r };
91    vec_ullong2 x1n_v = (vec_ullong2){ x2n, x3n };
92    vec_ullong2 x1d_v = (vec_ullong2){ x2d, x3d };
93    vec_ullong2 x1q_v = (vec_ullong2){ x2q, x3q };
94    vec_ullong2 x1r_v = (vec_ullong2){ x2r, x3r };
95    vec_ullong2 x2n_v = (vec_ullong2){ x4n, x5n };
96    vec_ullong2 x2d_v = (vec_ullong2){ x4d, x5d };
97    vec_ullong2 x2q_v = (vec_ullong2){ x4q, x5q };
98    vec_ullong2 x2r_v = (vec_ullong2){ x4r, x5r };
99    vec_ullong2 x3n_v = (vec_ullong2){ x6n, x7n };
100    vec_ullong2 x3d_v = (vec_ullong2){ x6d, x7d };
101    vec_ullong2 x3q_v = (vec_ullong2){ x6q, x7q };
102    vec_ullong2 x3r_v = (vec_ullong2){ x6r, x7r };
103    vec_ullong2 x4n_v = (vec_ullong2){ x8n, x9n };
104    vec_ullong2 x4d_v = (vec_ullong2){ x8d, x9d };
105    vec_ullong2 x4q_v = (vec_ullong2){ x8q, x9q };
106    vec_ullong2 x4r_v = (vec_ullong2){ x8r, x9r };
107    
108    lldivu2_t res;
109
110    TEST_START("lldivu2");
111    res = lldivu2(x0n_v, x0d_v);
112    TEST_CHECK("20060904200001MH", allequal_ullong2( res.quot, x0q_v ) && allequal_ullong2( res.rem,  x0r_v ), 0);
113    res = lldivu2(x1n_v, x1d_v);
114    TEST_CHECK("20060904200002MH", allequal_ullong2( res.quot, x1q_v ) && allequal_ullong2( res.rem,  x1r_v ), 0);
115    res = lldivu2(x2n_v, x2d_v);
116    TEST_CHECK("20060904200003MH", allequal_ullong2( res.quot, x2q_v ) && allequal_ullong2( res.rem,  x2r_v ), 0);
117    res = lldivu2(x3n_v, x3d_v);
118    TEST_CHECK("20060904200004MH", allequal_ullong2( res.quot, x3q_v ) && allequal_ullong2( res.rem,  x3r_v ), 0);
119    res = lldivu2(x4n_v, x4d_v);
120    TEST_CHECK("20060904200005MH", allequal_ullong2( res.quot, x4q_v ) && allequal_ullong2( res.rem,  x4r_v ), 0);
121    
122    TEST_SET_DONE();
123    
124    TEST_EXIT();
125 }