/ src / ref / remainder_piby2.c
remainder_piby2.c
 1  /*
 2   * Copyright (C) 2008-2020 Advanced Micro Devices, Inc. All rights reserved.
 3   *
 4   * Redistribution and use in source and binary forms, with or without modification,
 5   * are permitted provided that the following conditions are met:
 6   * 1. Redistributions of source code must retain the above copyright notice,
 7   *    this list of conditions and the following disclaimer.
 8   * 2. Redistributions in binary form must reproduce the above copyright notice,
 9   *    this list of conditions and the following disclaimer in the documentation
10   *    and/or other materials provided with the distribution.
11   * 3. Neither the name of the copyright holder nor the names of its contributors
12   *    may be used to endorse or promote products derived from this software without
13   *    specific prior written permission.
14   *
15   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16   * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17   * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18   * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
19   * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
20   * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
21   * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22   * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24   * POSSIBILITY OF SUCH DAMAGE.
25   *
26   */
27  
28  #include "libm_amd.h"
29  
30  void __amd_remainder_piby2(double x, double *r, double *rr, int *region);
31  
32  void __amd_remainder_2dfpiby2(__m128d x, __m128d *r, __m128d *rr, __m128i *region)
33  {
34  	union XMMREGTYP_
35  	{
36  
37  		__m128d d128;
38  		__m128i i128;
39  		double d[2];
40  		unsigned long long i[2];
41  	};
42  
43  	typedef union XMMREGTYP_ XMMREGTYP;
44  
45  
46  	XMMREGTYP inpx;
47  	XMMREGTYP resr,resrr,resregion;
48  	int reg,reg1;
49  	double irr,irr1,ir,ir1;
50  
51  
52  
53  	inpx.d128 = x;
54  
55       __amd_remainder_piby2(inpx.d[0],&ir,&irr,&reg);
56  	 __amd_remainder_piby2(inpx.d[1],&ir1,&irr1,&reg1);
57  
58  	 resregion.i[0] = reg;
59  	 resregion.i[1] = reg1;
60  
61  	 resrr.d[0] = irr;
62  	 resrr.d[1] = irr1;
63  
64  	 resr.d[0] = ir;
65  	 resr.d[1] = ir1;
66  
67  
68  
69  	*r = resr.d128;
70  	*rr = resrr.d128;
71  	*region = resregion.i128;
72  
73  }
74