ix86_expand_lround (rtx op0, rtx op1)
{
/* C code for the stuff we're doing below:
- tmp = op1 + copysign (nextafter (0.5, 0.0), op1)
- return (long)tmp;
+ tmp = op1 + copysign (nextafter (0.5, 0.0), op1)
+ return (long)tmp;
*/
machine_mode mode = GET_MODE (op1);
const struct real_format *fmt;
{
/* C code for the stuff we're doing below (for do_floor):
xi = (long)op1;
- xi -= (double)xi > op1 ? 1 : 0;
- return xi;
+ xi -= (double)xi > op1 ? 1 : 0;
+ return xi;
*/
machine_mode fmode = GET_MODE (op1);
machine_mode imode = GET_MODE (op0);
static rtx
ix86_gen_TWO52 (machine_mode mode)
{
+ const struct real_format *fmt;
REAL_VALUE_TYPE TWO52r;
rtx TWO52;
- real_ldexp (&TWO52r, &dconst1, mode == DFmode ? 52 : 23);
+ fmt = REAL_MODE_FORMAT (mode);
+ real_2expN (&TWO52r, fmt->p - 1, mode);
TWO52 = const_double_from_real_value (TWO52r, mode);
TWO52 = force_reg (mode, TWO52);
{
/* C code for the stuff we're doing below:
xa = fabs (operand1);
- if (!isless (xa, 2**52))
+ if (!isless (xa, 2**52))
return operand1;
- two52 = 2**52;
- if (flag_rounding_math)
+ two52 = 2**52;
+ if (flag_rounding_math)
{
two52 = copysign (two52, operand1);
xa = operand1;
}
- xa = xa + two52 - two52;
- return copysign (xa, operand1);
+ xa = xa + two52 - two52;
+ return copysign (xa, operand1);
*/
machine_mode mode = GET_MODE (operand0);
rtx res, xa, TWO52, mask;
rtx_code_label *label;
- res = gen_reg_rtx (mode);
- emit_move_insn (res, operand1);
+ TWO52 = ix86_gen_TWO52 (mode);
+
+ /* Temporary for holding the result, initialized to the input
+ operand to ease control flow. */
+ res = copy_to_reg (operand1);
/* xa = abs (operand1) */
xa = ix86_expand_sse_fabs (res, &mask);
/* if (!isless (xa, TWO52)) goto label; */
- TWO52 = ix86_gen_TWO52 (mode);
label = ix86_expand_sse_compare_and_jump (UNLE, TWO52, xa, false);
if (flag_rounding_math)
{
/* C code for the stuff we expand below.
double xa = fabs (x), x2;
- if (!isless (xa, TWO52))
- return x;
+ if (!isless (xa, TWO52))
+ return x;
x2 = (double)(long)x;
Compensate. Floor:
/* Temporary for holding the result, initialized to the input
operand to ease control flow. */
- res = gen_reg_rtx (mode);
- emit_move_insn (res, operand1);
+ res = copy_to_reg (operand1);
/* xa = abs (operand1) */
xa = ix86_expand_sse_fabs (res, &mask);
label = ix86_expand_sse_compare_and_jump (UNLE, TWO52, xa, false);
/* xa = (double)(long)x */
- xi = gen_reg_rtx (mode == DFmode ? DImode : SImode);
+ xi = gen_reg_rtx (int_mode_for_mode (mode).require ());
expand_fix (xi, res, 0);
expand_float (xa, xi, 0);
ix86_expand_floorceildf_32 (rtx operand0, rtx operand1, bool do_floor)
{
/* C code for the stuff we expand below.
- double xa = fabs (x), x2;
- if (!isless (xa, TWO52))
- return x;
- xa = xa + TWO52 - TWO52;
- x2 = copysign (xa, x);
+ double xa = fabs (x), x2;
+ if (!isless (xa, TWO52))
+ return x;
+ xa = xa + TWO52 - TWO52;
+ x2 = copysign (xa, x);
Compensate. Floor:
- if (x2 > x)
- x2 -= 1;
+ if (x2 > x)
+ x2 -= 1;
Compensate. Ceil:
- if (x2 < x)
- x2 += 1;
+ if (x2 < x)
+ x2 += 1;
if (HONOR_SIGNED_ZEROS (mode))
x2 = copysign (x2, x);
/* Temporary for holding the result, initialized to the input
operand to ease control flow. */
- res = gen_reg_rtx (mode);
- emit_move_insn (res, operand1);
+ res = copy_to_reg (operand1);
/* xa = abs (operand1) */
xa = ix86_expand_sse_fabs (res, &mask);
ix86_expand_trunc (rtx operand0, rtx operand1)
{
/* C code for SSE variant we expand below.
- double xa = fabs (x), x2;
- if (!isless (xa, TWO52))
- return x;
- x2 = (double)(long)x;
+ double xa = fabs (x), x2;
+ if (!isless (xa, TWO52))
+ return x;
+ x2 = (double)(long)x;
if (HONOR_SIGNED_ZEROS (mode))
return copysign (x2, x);
return x2;
/* Temporary for holding the result, initialized to the input
operand to ease control flow. */
- res = gen_reg_rtx (mode);
- emit_move_insn (res, operand1);
+ res = copy_to_reg (operand1);
/* xa = abs (operand1) */
xa = ix86_expand_sse_fabs (res, &mask);
label = ix86_expand_sse_compare_and_jump (UNLE, TWO52, xa, false);
/* xa = (double)(long)x */
- xi = gen_reg_rtx (mode == DFmode ? DImode : SImode);
+ xi = gen_reg_rtx (int_mode_for_mode (mode).require ());
expand_fix (xi, res, 0);
expand_float (xa, xi, 0);
rtx_code_label *label;
/* C code for SSE variant we expand below.
- double xa = fabs (x), x2;
- if (!isless (xa, TWO52))
- return x;
- xa2 = xa + TWO52 - TWO52;
+ double xa = fabs (x), x2;
+ if (!isless (xa, TWO52))
+ return x;
+ xa2 = xa + TWO52 - TWO52;
Compensate:
- if (xa2 > xa)
- xa2 -= 1.0;
- x2 = copysign (xa2, x);
- return x2;
+ if (xa2 > xa)
+ xa2 -= 1.0;
+ x2 = copysign (xa2, x);
+ return x2;
*/
TWO52 = ix86_gen_TWO52 (mode);
/* Temporary for holding the result, initialized to the input
operand to ease control flow. */
- res = gen_reg_rtx (mode);
- emit_move_insn (res, operand1);
+ res =copy_to_reg (operand1);
/* xa = abs (operand1) */
xa = ix86_expand_sse_fabs (res, &mask);
ix86_expand_round (rtx operand0, rtx operand1)
{
/* C code for the stuff we're doing below:
- double xa = fabs (x);
- if (!isless (xa, TWO52))
- return x;
- xa = (double)(long)(xa + nextafter (0.5, 0.0));
- return copysign (xa, x);
+ double xa = fabs (x);
+ if (!isless (xa, TWO52))
+ return x;
+ xa = (double)(long)(xa + nextafter (0.5, 0.0));
+ return copysign (xa, x);
*/
machine_mode mode = GET_MODE (operand0);
rtx res, TWO52, xa, xi, half, mask;
/* Temporary for holding the result, initialized to the input
operand to ease control flow. */
- res = gen_reg_rtx (mode);
- emit_move_insn (res, operand1);
+ res = copy_to_reg (operand1);
TWO52 = ix86_gen_TWO52 (mode);
xa = ix86_expand_sse_fabs (res, &mask);
xa = expand_simple_binop (mode, PLUS, xa, half, NULL_RTX, 0, OPTAB_DIRECT);
/* xa = (double)(int64_t)xa */
- xi = gen_reg_rtx (mode == DFmode ? DImode : SImode);
+ xi = gen_reg_rtx (int_mode_for_mode (mode).require ());
expand_fix (xi, xa, 0);
expand_float (xa, xi, 0);
ix86_expand_rounddf_32 (rtx operand0, rtx operand1)
{
/* C code for the stuff we expand below.
- double xa = fabs (x), xa2, x2;
- if (!isless (xa, TWO52))
- return x;
+ double xa = fabs (x), xa2, x2;
+ if (!isless (xa, TWO52))
+ return x;
Using the absolute value and copying back sign makes
-0.0 -> -0.0 correct.
- xa2 = xa + TWO52 - TWO52;
+ xa2 = xa + TWO52 - TWO52;
Compensate.
dxa = xa2 - xa;
- if (dxa <= -0.5)
- xa2 += 1;
- else if (dxa > 0.5)
- xa2 -= 1;
- x2 = copysign (xa2, x);
- return x2;
+ if (dxa <= -0.5)
+ xa2 += 1;
+ else if (dxa > 0.5)
+ xa2 -= 1;
+ x2 = copysign (xa2, x);
+ return x2;
*/
machine_mode mode = GET_MODE (operand0);
rtx xa, xa2, dxa, TWO52, tmp, half, mhalf, one, res, mask;
/* Temporary for holding the result, initialized to the input
operand to ease control flow. */
- res = gen_reg_rtx (mode);
- emit_move_insn (res, operand1);
+ res = copy_to_reg (operand1);
/* xa = abs (operand1) */
xa = ix86_expand_sse_fabs (res, &mask);