]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR target/26915 (missed sized opt returning -1.0)
authorUros Bizjak <ubizjak@gmail.com>
Sat, 4 Nov 2006 23:12:16 +0000 (00:12 +0100)
committerUros Bizjak <uros@gcc.gnu.org>
Sat, 4 Nov 2006 23:12:16 +0000 (00:12 +0100)
        PR target/26915
        * config/i386/i386.c (standard_80387_constant_p): Treat -0.0 and -1.0
        as a valid 80387 constant.
        (standard_80387_constant_opcode): Return "#" for -0.0 and -1.0.
        * config/i386/i386.md (unnamed splitter): Split the load of
        constant -0.0 or -1.0  into the load of 0.0 or 1.0, followed
        by negation.

testsuite/ChangeLog:

        PR target/26915
        * gcc.target/i386/387-12.c: New test.
~

From-SVN: r118484

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/config/i386/i386.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/387-12.c [new file with mode: 0644]

index d77ae3e67dfb93f6a7c58b110942424b7a722895..81ae94fc47ca48ac94894e49501e164c03ef29e0 100644 (file)
@@ -1,3 +1,13 @@
+2006-11-04  Uros Bizjak  <ubizjak@gmail.com>
+
+       PR target/26915
+       * config/i386/i386.c (standard_80387_constant_p): Treat -0.0 and -1.0
+       as a valid 80387 constant.
+       (standard_80387_constant_opcode): Return "#" for -0.0 and -1.0.
+       * config/i386/i386.md (unnamed splitter): Split the load of
+       constant -0.0 or -1.0  into the load of 0.0 or 1.0, followed
+       by negation.
+
 2006-11-04  Richard Earnshaw  <rearnsha@arm.com>
 
        * arm.c (thumb_legitimate_addres_p): Allow any constant offset
@@ -8,7 +18,6 @@
        * config/i386/i386.md (*movxf_nointeger, *movxf_integer): Enable
        patterns for standard 80387 constants.
 
-
 2006-11-03  Paolo Bonzini  <bonzini@gnu.org>
            Steven Bosscher  <steven@gcc.gnu.org>
 
index d2e19a0c293f6dec1759a2207461811d23f46593..cd4162860151ccb9efce00a108779a640ba2bbcd 100644 (file)
@@ -4575,6 +4575,8 @@ init_ext_80387_constants (void)
 int
 standard_80387_constant_p (rtx x)
 {
+  REAL_VALUE_TYPE r;
+
   if (GET_CODE (x) != CONST_DOUBLE || !FLOAT_MODE_P (GET_MODE (x)))
     return -1;
 
@@ -4583,23 +4585,30 @@ standard_80387_constant_p (rtx x)
   if (x == CONST1_RTX (GET_MODE (x)))
     return 2;
 
+  REAL_VALUE_FROM_CONST_DOUBLE (r, x);
+
   /* For XFmode constants, try to find a special 80387 instruction when
      optimizing for size or on those CPUs that benefit from them.  */
   if (GET_MODE (x) == XFmode
       && (optimize_size || x86_ext_80387_constants & TUNEMASK))
     {
-      REAL_VALUE_TYPE r;
       int i;
 
       if (! ext_80387_constants_init)
        init_ext_80387_constants ();
 
-      REAL_VALUE_FROM_CONST_DOUBLE (r, x);
       for (i = 0; i < 5; i++)
         if (real_identical (&r, &ext_80387_constants_table[i]))
          return i + 3;
     }
 
+  /* Load of the constant -0.0 or -1.0 will be split as
+     fldz;fchs or fld1;fchs sequence.  */
+  if (real_isnegzero (&r))
+    return 8;
+  if (real_identical (&r, &dconstm1))
+    return 9;
+
   return 0;
 }
 
@@ -4625,6 +4634,9 @@ standard_80387_constant_opcode (rtx x)
       return "fldl2t";
     case 7:
       return "fldpi";
+    case 8:
+    case 9:
+      return "#";
     default:
       gcc_unreachable ();
     }
index 94f9f57ca7a76d503597f68cd191873f3a77e68b..28de0a4b7d7c077fde3216db101ad1adf341bc65 100644 (file)
   [(set_attr "type" "fxch")
    (set_attr "mode" "XF")])
 
+;; Split the load of -0.0 or -1.0 into fldz;fchs or fld1;fchs sequence
+(define_split
+  [(set (match_operand:X87MODEF 0 "register_operand" "")
+       (match_operand:X87MODEF 1 "immediate_operand" ""))]
+  "reload_completed && FP_REGNO_P (REGNO (operands[0]))
+   && (standard_80387_constant_p (operands[1]) == 8
+       || standard_80387_constant_p (operands[1]) == 9)"
+  [(set (match_dup 0)(match_dup 1))
+   (set (match_dup 0)
+       (neg:X87MODEF (match_dup 0)))]
+{
+  REAL_VALUE_TYPE r;
+
+  REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
+  if (real_isnegzero (&r))
+    operands[1] = CONST0_RTX (<MODE>mode);
+  else
+    operands[1] = CONST1_RTX (<MODE>mode);
+})
+
 (define_expand "movtf"
   [(set (match_operand:TF 0 "nonimmediate_operand" "")
        (match_operand:TF 1 "nonimmediate_operand" ""))]
index 6ca95da9743a7e814852239a3c2a0e181dc1bb4f..925f5b3d38eb2545c83057d8b0ab935ca23ddddb 100644 (file)
@@ -1,3 +1,8 @@
+2006-11-04  Uros Bizjak  <ubizjak@gmail.com>
+
+       PR target/26915
+       * gcc.target/i386/387-12.c: New test.
+
 2006-11-04  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
 
        PR libfortran/29713
diff --git a/gcc/testsuite/gcc.target/i386/387-12.c b/gcc/testsuite/gcc.target/i386/387-12.c
new file mode 100644 (file)
index 0000000..c653974
--- /dev/null
@@ -0,0 +1,17 @@
+/* PR target/26915 */
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-require-effective-target ilp32 } */
+/* { dg-options "-O" } */
+
+double testm0(void)
+{
+       return -0.0;
+}
+
+double testm1(void)
+{
+       return -1.0;
+}
+
+/* { dg-final { scan-assembler "fldz" } } */
+/* { dg-final { scan-assembler "fld1" } } */