i386.c (ix86_expand_fp_absneg_operator): When SSE isn't available...
authorRoger Sayle <roger@eyesopen.com>
Thu, 1 Jun 2006 01:37:17 +0000 (01:37 +0000)
committerRoger Sayle <sayle@gcc.gnu.org>
Thu, 1 Jun 2006 01:37:17 +0000 (01:37 +0000)
* config/i386/i386.c (ix86_expand_fp_absneg_operator): When SSE
isn't available, directly generate the simpler x87 patterns without
the (use (const_int 0)).
* config/i386/i386.md (*negsf2_1): Enable pre-reload if the SSE
implementation isn't available.
(*negdf2_1): Likewise.
(*negxf2_1): XF mode negation is always done using the x87.
(*abssf2_1, *absdf2_1, *absxf2_1): Likewise^3 for fabs.

* gcc.target/i386/387-11.c: New test case.

From-SVN: r114293

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

index 4dcbbf1..0ecbe42 100644 (file)
@@ -1,5 +1,16 @@
 2006-05-31  Roger Sayle  <roger@eyesopen.com>
 
+       * config/i386/i386.c (ix86_expand_fp_absneg_operator): When SSE
+       isn't available, directly generate the simpler x87 patterns without
+       the (use (const_int 0)).
+       * config/i386/i386.md (*negsf2_1): Enable pre-reload if the SSE
+       implementation isn't available.
+       (*negdf2_1): Likewise.
+       (*negxf2_1): XF mode negation is always done using the x87.
+       (*abssf2_1, *absdf2_1, *absxf2_1): Likewise^3 for fabs.
+
+2006-05-31  Roger Sayle  <roger@eyesopen.com>
+
        * builtins.c (fold_builtin_cabs): Delete prototype.  Require an
        additional FNDECL argument.  Optimize cabs(-z) and cabs(~z) as
        cabs(z).
index 8c33150..145fc2e 100644 (file)
@@ -9288,22 +9288,17 @@ ix86_expand_fp_absneg_operator (enum rtx_code code, enum machine_mode mode,
   if (use_sse)
     mask = ix86_build_signbit_mask (elt_mode, vector_mode, code == ABS);
   else
-    {
-      /* When not using SSE, we don't use the mask, but prefer to keep the
-        same general form of the insn pattern to reduce duplication when
-        it comes time to split.  */
-      mask = const0_rtx;
-    }
+    mask = NULL_RTX;
 
   dst = operands[0];
   src = operands[1];
 
   /* If the destination is memory, and we don't have matching source
-     operands, do things in registers.  */
+     operands or we're using the x87, do things in registers.  */
   matching_memory = false;
   if (MEM_P (dst))
     {
-      if (rtx_equal_p (dst, src))
+      if (use_sse && rtx_equal_p (dst, src))
        matching_memory = true;
       else
        dst = gen_reg_rtx (mode);
@@ -9321,9 +9316,15 @@ ix86_expand_fp_absneg_operator (enum rtx_code code, enum machine_mode mode,
     {
       set = gen_rtx_fmt_e (code, mode, src);
       set = gen_rtx_SET (VOIDmode, dst, set);
-      use = gen_rtx_USE (VOIDmode, mask);
-      clob = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (CCmode, FLAGS_REG));
-      emit_insn (gen_rtx_PARALLEL (VOIDmode, gen_rtvec (3, set, use, clob)));
+      if (mask)
+        {
+          use = gen_rtx_USE (VOIDmode, mask);
+          clob = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (CCmode, FLAGS_REG));
+          emit_insn (gen_rtx_PARALLEL (VOIDmode,
+                                      gen_rtvec (3, set, use, clob)));
+        }
+      else
+       emit_insn (set);
     }
 
   if (dst != operands[0])
index a298e1b..8380561 100644 (file)
 (define_insn "*negsf2_1"
   [(set (match_operand:SF 0 "register_operand" "=f")
        (neg:SF (match_operand:SF 1 "register_operand" "0")))]
-  "TARGET_80387 && reload_completed"
+  "TARGET_80387 && (reload_completed || !TARGET_SSE_MATH)"
   "fchs"
   [(set_attr "type" "fsgn")
    (set_attr "mode" "SF")])
 (define_insn "*negdf2_1"
   [(set (match_operand:DF 0 "register_operand" "=f")
        (neg:DF (match_operand:DF 1 "register_operand" "0")))]
-  "TARGET_80387 && reload_completed"
+  "TARGET_80387 && (reload_completed || !TARGET_SSE_MATH)"
   "fchs"
   [(set_attr "type" "fsgn")
    (set_attr "mode" "DF")])
 (define_insn "*negxf2_1"
   [(set (match_operand:XF 0 "register_operand" "=f")
        (neg:XF (match_operand:XF 1 "register_operand" "0")))]
-  "TARGET_80387 && reload_completed"
+  "TARGET_80387"
   "fchs"
   [(set_attr "type" "fsgn")
    (set_attr "mode" "XF")])
 (define_insn "*abssf2_1"
   [(set (match_operand:SF 0 "register_operand" "=f")
        (abs:SF (match_operand:SF 1 "register_operand" "0")))]
-  "TARGET_80387 && reload_completed"
+  "TARGET_80387 && (reload_completed || !TARGET_SSE_MATH)"
   "fabs"
   [(set_attr "type" "fsgn")
    (set_attr "mode" "SF")])
 (define_insn "*absdf2_1"
   [(set (match_operand:DF 0 "register_operand" "=f")
        (abs:DF (match_operand:DF 1 "register_operand" "0")))]
-  "TARGET_80387 && reload_completed"
+  "TARGET_80387 && (reload_completed || !TARGET_SSE_MATH)"
   "fabs"
   [(set_attr "type" "fsgn")
    (set_attr "mode" "DF")])
 (define_insn "*absxf2_1"
   [(set (match_operand:XF 0 "register_operand" "=f")
        (abs:XF (match_operand:XF 1 "register_operand" "0")))]
-  "TARGET_80387 && reload_completed"
+  "TARGET_80387"
   "fabs"
   [(set_attr "type" "fsgn")
    (set_attr "mode" "DF")])
index 7277f60..c1f6dec 100644 (file)
@@ -1,3 +1,7 @@
+2006-05-31  Roger Sayle  <roger@eyesopen.com>
+
+       * gcc.target/i386/387-11.c: New test case.
+
 2006-05-31  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/27801
diff --git a/gcc/testsuite/gcc.target/i386/387-11.c b/gcc/testsuite/gcc.target/i386/387-11.c
new file mode 100644 (file)
index 0000000..cb55a93
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-O2 -mfpmath=387" } */
+
+double foo(double x, double y)
+{
+  double t = -x * y;
+  return -t;
+}
+
+/* { dg-final { scan-assembler-not "fchs" } } */