comparison libgcc/config/libbid/bid128_div.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents a06113de4d67
children 84e7813d76e9
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 /* Copyright (C) 2007, 2009 Free Software Foundation, Inc. 1 /* Copyright (C) 2007-2017 Free Software Foundation, Inc.
2 2
3 This file is part of GCC. 3 This file is part of GCC.
4 4
5 GCC is free software; you can redistribute it and/or modify it under 5 GCC is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free 6 the terms of the GNU General Public License as published by the Free
34 extern UINT8 packed_10000_zeros[]; 34 extern UINT8 packed_10000_zeros[];
35 35
36 BID128_FUNCTION_ARG2 (bid128_div, x, y) 36 BID128_FUNCTION_ARG2 (bid128_div, x, y)
37 37
38 UINT256 CA4, CA4r, P256; 38 UINT256 CA4, CA4r, P256;
39 UINT128 CX, CY, T128, CQ, CR, CA, TP128, Qh, Ql, res; 39 UINT128 CX, CY, T128, CQ, CR, CA, TP128, Qh, res;
40 UINT64 sign_x, sign_y, T, carry64, D, Q_high, Q_low, QX, PD, 40 UINT64 sign_x, sign_y, T, carry64, D, Q_high, Q_low, QX, PD,
41 valid_y; 41 valid_y;
42 int_float fx, fy, f64; 42 int_float fx, fy, f64;
43 UINT32 QX32, tdigit[3], digit, digit_h, digit_low; 43 UINT32 QX32, tdigit[3], digit, digit_h, digit_low;
44 int exponent_x, exponent_y, bin_index, bin_expon, diff_expon, ed2, 44 int exponent_x, exponent_y, bin_index, bin_expon, diff_expon, ed2,
237 // difference in powers of 5 factors 237 // difference in powers of 5 factors
238 d5 = ed2 - factors[i][1] + factors[j][1]; 238 d5 = ed2 - factors[i][1] + factors[j][1];
239 if (d5 < nzeros) 239 if (d5 < nzeros)
240 nzeros = d5; 240 nzeros = d5;
241 // get P*(2^M[extra_digits])/10^extra_digits 241 // get P*(2^M[extra_digits])/10^extra_digits
242 __mul_128x128_full (Qh, Ql, CQ, reciprocals10_128[nzeros]); 242 __mul_128x128_high (Qh, CQ, reciprocals10_128[nzeros]);
243 243
244 // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128 244 // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128
245 amount = recip_scale[nzeros]; 245 amount = recip_scale[nzeros];
246 __shr_128_long (CQ, Qh, amount); 246 __shr_128_long (CQ, Qh, amount);
247 247
363 (digit_h & 7)); 363 (digit_h & 7));
364 } 364 }
365 365
366 if (nzeros) { 366 if (nzeros) {
367 // get P*(2^M[extra_digits])/10^extra_digits 367 // get P*(2^M[extra_digits])/10^extra_digits
368 __mul_128x128_full (Qh, Ql, CQ, reciprocals10_128[nzeros]); 368 __mul_128x128_high (Qh, CQ, reciprocals10_128[nzeros]);
369 369
370 //now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128 370 //now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128
371 amount = recip_scale[nzeros]; 371 amount = recip_scale[nzeros];
372 __shr_128 (CQ, Qh, amount); 372 __shr_128 (CQ, Qh, amount);
373 } 373 }
485 485
486 TYPE0_FUNCTION_ARGTYPE1_ARGTYPE2 (UINT128, bid128dd_div, UINT64, x, 486 TYPE0_FUNCTION_ARGTYPE1_ARGTYPE2 (UINT128, bid128dd_div, UINT64, x,
487 UINT64, y) 487 UINT64, y)
488 488
489 UINT256 CA4, CA4r, P256; 489 UINT256 CA4, CA4r, P256;
490 UINT128 CX, CY, T128, CQ, CR, CA, TP128, Qh, Ql, res; 490 UINT128 CX, CY, T128, CQ, CR, CA, TP128, Qh, res;
491 UINT64 sign_x, sign_y, T, carry64, D, Q_high, Q_low, QX, PD, 491 UINT64 sign_x, sign_y, T, carry64, D, Q_high, Q_low, QX, PD,
492 valid_y; 492 valid_y;
493 int_float fx, fy, f64; 493 int_float fx, fy, f64;
494 UINT32 QX32, tdigit[3], digit, digit_h, digit_low; 494 UINT32 QX32, tdigit[3], digit, digit_h, digit_low;
495 int exponent_x, exponent_y, bin_index, bin_expon, diff_expon, ed2, 495 int exponent_x, exponent_y, bin_index, bin_expon, diff_expon, ed2,
699 // difference in powers of 5 factors 699 // difference in powers of 5 factors
700 d5 = ed2 - factors[i][1] + factors[j][1]; 700 d5 = ed2 - factors[i][1] + factors[j][1];
701 if (d5 < nzeros) 701 if (d5 < nzeros)
702 nzeros = d5; 702 nzeros = d5;
703 // get P*(2^M[extra_digits])/10^extra_digits 703 // get P*(2^M[extra_digits])/10^extra_digits
704 __mul_128x128_full (Qh, Ql, CQ, reciprocals10_128[nzeros]); 704 __mul_128x128_high (Qh, CQ, reciprocals10_128[nzeros]);
705 //__mul_128x128_to_256(P256, CQ, reciprocals10_128[nzeros]);Qh.w[1]=P256.w[3];Qh.w[0]=P256.w[2]; 705 //__mul_128x128_to_256(P256, CQ, reciprocals10_128[nzeros]);Qh.w[1]=P256.w[3];Qh.w[0]=P256.w[2];
706 706
707 // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128 707 // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128
708 amount = recip_scale[nzeros]; 708 amount = recip_scale[nzeros];
709 __shr_128_long (CQ, Qh, amount); 709 __shr_128_long (CQ, Qh, amount);
827 (digit_h & 7)); 827 (digit_h & 7));
828 } 828 }
829 829
830 if (nzeros) { 830 if (nzeros) {
831 // get P*(2^M[extra_digits])/10^extra_digits 831 // get P*(2^M[extra_digits])/10^extra_digits
832 __mul_128x128_full (Qh, Ql, CQ, reciprocals10_128[nzeros]); 832 __mul_128x128_high (Qh, CQ, reciprocals10_128[nzeros]);
833 833
834 // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128 834 // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128
835 amount = recip_scale[nzeros]; 835 amount = recip_scale[nzeros];
836 __shr_128 (CQ, Qh, amount); 836 __shr_128 (CQ, Qh, amount);
837 } 837 }
944 } 944 }
945 945
946 946
947 BID128_FUNCTION_ARGTYPE1_ARG128 (bid128dq_div, UINT64, x, y) 947 BID128_FUNCTION_ARGTYPE1_ARG128 (bid128dq_div, UINT64, x, y)
948 UINT256 CA4, CA4r, P256; 948 UINT256 CA4, CA4r, P256;
949 UINT128 CX, CY, T128, CQ, CR, CA, TP128, Qh, Ql, res; 949 UINT128 CX, CY, T128, CQ, CR, CA, TP128, Qh, res;
950 UINT64 sign_x, sign_y, T, carry64, D, Q_high, Q_low, QX, valid_y, 950 UINT64 sign_x, sign_y, T, carry64, D, Q_high, Q_low, QX, valid_y,
951 PD; 951 PD;
952 int_float fx, fy, f64; 952 int_float fx, fy, f64;
953 UINT32 QX32, tdigit[3], digit, digit_h, digit_low; 953 UINT32 QX32, tdigit[3], digit, digit_h, digit_low;
954 int exponent_x, exponent_y, bin_index, bin_expon, diff_expon, ed2, 954 int exponent_x, exponent_y, bin_index, bin_expon, diff_expon, ed2,
1153 // difference in powers of 5 factors 1153 // difference in powers of 5 factors
1154 d5 = ed2 - factors[i][1] + factors[j][1]; 1154 d5 = ed2 - factors[i][1] + factors[j][1];
1155 if (d5 < nzeros) 1155 if (d5 < nzeros)
1156 nzeros = d5; 1156 nzeros = d5;
1157 // get P*(2^M[extra_digits])/10^extra_digits 1157 // get P*(2^M[extra_digits])/10^extra_digits
1158 __mul_128x128_full (Qh, Ql, CQ, reciprocals10_128[nzeros]); 1158 __mul_128x128_high (Qh, CQ, reciprocals10_128[nzeros]);
1159 //__mul_128x128_to_256(P256, CQ, reciprocals10_128[nzeros]);Qh.w[1]=P256.w[3];Qh.w[0]=P256.w[2]; 1159 //__mul_128x128_to_256(P256, CQ, reciprocals10_128[nzeros]);Qh.w[1]=P256.w[3];Qh.w[0]=P256.w[2];
1160 1160
1161 // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128 1161 // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128
1162 amount = recip_scale[nzeros]; 1162 amount = recip_scale[nzeros];
1163 __shr_128_long (CQ, Qh, amount); 1163 __shr_128_long (CQ, Qh, amount);
1283 (digit_h & 7)); 1283 (digit_h & 7));
1284 } 1284 }
1285 1285
1286 if (nzeros) { 1286 if (nzeros) {
1287 // get P*(2^M[extra_digits])/10^extra_digits 1287 // get P*(2^M[extra_digits])/10^extra_digits
1288 __mul_128x128_full (Qh, Ql, CQ, reciprocals10_128[nzeros]); 1288 __mul_128x128_high (Qh, CQ, reciprocals10_128[nzeros]);
1289 1289
1290 // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128 1290 // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128
1291 amount = recip_scale[nzeros]; 1291 amount = recip_scale[nzeros];
1292 __shr_128 (CQ, Qh, amount); 1292 __shr_128 (CQ, Qh, amount);
1293 } 1293 }
1401 } 1401 }
1402 1402
1403 1403
1404 BID128_FUNCTION_ARG128_ARGTYPE2 (bid128qd_div, x, UINT64, y) 1404 BID128_FUNCTION_ARG128_ARGTYPE2 (bid128qd_div, x, UINT64, y)
1405 UINT256 CA4, CA4r, P256; 1405 UINT256 CA4, CA4r, P256;
1406 UINT128 CX, CY, T128, CQ, CR, CA, TP128, Qh, Ql, res; 1406 UINT128 CX, CY, T128, CQ, CR, CA, TP128, Qh, res;
1407 UINT64 sign_x, sign_y, T, carry64, D, Q_high, Q_low, QX, PD, 1407 UINT64 sign_x, sign_y, T, carry64, D, Q_high, Q_low, QX, PD,
1408 valid_y; 1408 valid_y;
1409 int_float fx, fy, f64; 1409 int_float fx, fy, f64;
1410 UINT32 QX32, tdigit[3], digit, digit_h, digit_low; 1410 UINT32 QX32, tdigit[3], digit, digit_h, digit_low;
1411 int exponent_x, exponent_y, bin_index, bin_expon, diff_expon, ed2, 1411 int exponent_x, exponent_y, bin_index, bin_expon, diff_expon, ed2,
1605 // difference in powers of 5 factors 1605 // difference in powers of 5 factors
1606 d5 = ed2 - factors[i][1] + factors[j][1]; 1606 d5 = ed2 - factors[i][1] + factors[j][1];
1607 if (d5 < nzeros) 1607 if (d5 < nzeros)
1608 nzeros = d5; 1608 nzeros = d5;
1609 // get P*(2^M[extra_digits])/10^extra_digits 1609 // get P*(2^M[extra_digits])/10^extra_digits
1610 __mul_128x128_full (Qh, Ql, CQ, reciprocals10_128[nzeros]); 1610 __mul_128x128_high (Qh, CQ, reciprocals10_128[nzeros]);
1611 //__mul_128x128_to_256(P256, CQ, reciprocals10_128[nzeros]);Qh.w[1]=P256.w[3];Qh.w[0]=P256.w[2]; 1611 //__mul_128x128_to_256(P256, CQ, reciprocals10_128[nzeros]);Qh.w[1]=P256.w[3];Qh.w[0]=P256.w[2];
1612 1612
1613 // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128 1613 // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128
1614 amount = recip_scale[nzeros]; 1614 amount = recip_scale[nzeros];
1615 __shr_128_long (CQ, Qh, amount); 1615 __shr_128_long (CQ, Qh, amount);
1733 (digit_h & 7)); 1733 (digit_h & 7));
1734 } 1734 }
1735 1735
1736 if (nzeros) { 1736 if (nzeros) {
1737 // get P*(2^M[extra_digits])/10^extra_digits 1737 // get P*(2^M[extra_digits])/10^extra_digits
1738 __mul_128x128_full (Qh, Ql, CQ, reciprocals10_128[nzeros]); 1738 __mul_128x128_high (Qh, CQ, reciprocals10_128[nzeros]);
1739 1739
1740 // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128 1740 // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128
1741 amount = recip_scale[nzeros]; 1741 amount = recip_scale[nzeros];
1742 __shr_128 (CQ, Qh, amount); 1742 __shr_128 (CQ, Qh, amount);
1743 } 1743 }