From: Uros Bizjak Date: Tue, 19 Jun 2007 11:22:24 +0000 (+0200) Subject: i386.c (ix86_emit_swsqrtsf): Limit the result of rsqrt insn to FLT_MAX to avoid NaN... X-Git-Tag: releases/gcc-4.3.0~4389 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=258d0b9b9e7ca27b5e7e3a2dbb1488a9f4e13bfd;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 362eda2b88fd..3b9f881348d2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2007-06-18 Uros Bizjak + + * 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 PR middle-end/31950 diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 72e281ec173d..204373c82ba4 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -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)));