OSDN Git Service

* config/i386/i386.c (ix86_emit_swsqrtsf): Limit the result of
authoruros <uros@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 19 Jun 2007 11:22:24 +0000 (11:22 +0000)
committeruros <uros@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 19 Jun 2007 11:22:24 +0000 (11:22 +0000)
rsqrt insn to FLT_MAX to avoid NaN for zero input argument.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@125847 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/i386/i386.c

index 362eda2..3b9f881 100644 (file)
@@ -1,3 +1,8 @@
+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
index 72e281e..204373c 100644 (file)
@@ -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)));