Commit 258d0b9b by Uros Bizjak Committed by Uros Bizjak

i386.c (ix86_emit_swsqrtsf): Limit the result of rsqrt insn to FLT_MAX to avoid…

i386.c (ix86_emit_swsqrtsf): Limit the result of rsqrt insn to FLT_MAX to avoid NaN for zero input argument.

	* config/i386/i386.c (ix86_emit_swsqrtsf): Limit the result of
	rsqrt insn to FLT_MAX to avoid NaN for zero input argument.

From-SVN: r125847
parent 7ffc27a6
2007-06-18 Uros Bizjak <ubizjak@gmail.com>
* config/i386/i386.c (ix86_emit_swsqrtsf): Limit the result of
rsqrt insn to FLT_MAX to avoid NaN for zero input argument.
2007-06-19 Richard Guenther <rguenther@suse.de>
PR middle-end/31950
......
......@@ -22593,7 +22593,7 @@ void ix86_emit_swdivsf (rtx res, rtx a, rtx b, enum machine_mode mode)
void ix86_emit_swsqrtsf (rtx res, rtx a, enum machine_mode mode,
bool recip)
{
rtx x0, e0, e1, e2, e3, three, half;
rtx x0, e0, e1, e2, e3, three, half, bignum;
x0 = gen_reg_rtx (mode);
e0 = gen_reg_rtx (mode);
......@@ -22603,15 +22603,18 @@ void ix86_emit_swsqrtsf (rtx res, rtx a, enum machine_mode mode,
three = CONST_DOUBLE_FROM_REAL_VALUE (dconst3, SFmode);
half = CONST_DOUBLE_FROM_REAL_VALUE (dconsthalf, SFmode);
bignum = gen_lowpart (SFmode, GEN_INT (0x7f7fffff));
if (VECTOR_MODE_P (mode))
{
three = ix86_build_const_vector (SFmode, true, three);
half = ix86_build_const_vector (SFmode, true, half);
bignum = ix86_build_const_vector (SFmode, true, bignum);
}
three = force_reg (mode, three);
half = force_reg (mode, half);
bignum = force_reg (mode, bignum);
/* sqrt(a) = 0.5 * a * rsqrtss(a) * (3.0 - a * rsqrtss(a) * rsqrtss(a))
1.0 / sqrt(a) = 0.5 * rsqrtss(a) * (3.0 - a * rsqrtss(a) * rsqrtss(a)) */
......@@ -22620,6 +22623,9 @@ void ix86_emit_swsqrtsf (rtx res, rtx a, enum machine_mode mode,
emit_insn (gen_rtx_SET (VOIDmode, x0,
gen_rtx_UNSPEC (mode, gen_rtvec (1, a),
UNSPEC_RSQRT)));
emit_insn (gen_rtx_SET (VOIDmode, x0,
gen_rtx_SMIN (mode, x0, bignum)));
/* e0 = x0 * a */
emit_insn (gen_rtx_SET (VOIDmode, e0,
gen_rtx_MULT (mode, x0, a)));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment