This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix PR target/19240


Hello!

This patch fixes target/19240, where we emit a 387 instructions for TARGET_SSE_MATH. The problem was, that some i387 patterns were not fully shadowed by corresponding SSE pattern. This patch disables these i387 patterns for TARGET_SSE_MATH.

Patch was bootstrapped on pentium4-pc-linux-gnu, regtesting is in progress.

OK for mainline?

BTW: As it is claimed by reporter, mixing 387 and SSE code can introduce ~15% slowdown for FP intensive code. I would like to point on similar problem with FP compares (http://gcc.gnu.org/ml/gcc/2004-12/msg01029.html) and PR target/19009, where SSE code is generated when -mfpmath=387 is specified and vice versa. For pentium4, FP->SSE and SSE->FP moves are not cheap at all. The latency of movsd from/to memory and the latency of fld/fst to/from memory is ~7 cycles for every insn! This means that the latency of move to/from memory is more than the latency of FP multiply insn.

2005-01-04 Uros Bizjak <uros@kss-loka.si>

   PR target/19240
   * config/i386/i386.md (*fop_df_1_i387): Disable for TARGET_SSE_MATH.
   (*fop_df_1_i387): Disable for (TARGET_SSE2 && TARGET_SSE_MATH).

Uros.
Index: i386.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.md,v
retrieving revision 1.597
diff -u -r1.597 i386.md
--- i386.md	3 Jan 2005 09:54:53 -0000	1.597
+++ i386.md	4 Jan 2005 07:02:53 -0000
@@ -14192,12 +14192,13 @@
               (const_string "sseadd")))
    (set_attr "mode" "SF")])
 
+;; This pattern is not fully shadowed by the pattern above.
 (define_insn "*fop_sf_1_i387"
   [(set (match_operand:SF 0 "register_operand" "=f,f")
 	(match_operator:SF 3 "binary_fp_operator"
 			[(match_operand:SF 1 "nonimmediate_operand" "0,fm")
 			 (match_operand:SF 2 "nonimmediate_operand" "fm,0")]))]
-  "TARGET_80387
+  "TARGET_80387 && !TARGET_SSE_MATH
    && !COMMUTATIVE_ARITH_P (operands[3])
    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
   "* return output_387_binary_op (insn, operands);"
@@ -14338,12 +14339,13 @@
               ]
               (const_string "sseadd")))])
 
+;; This pattern is not fully shadowed by the pattern above.
 (define_insn "*fop_df_1_i387"
   [(set (match_operand:DF 0 "register_operand" "=f,f")
 	(match_operator:DF 3 "binary_fp_operator"
 			[(match_operand:DF 1 "nonimmediate_operand" "0,fm")
 			 (match_operand:DF 2 "nonimmediate_operand" "fm,0")]))]
-  "TARGET_80387
+  "TARGET_80387 && !(TARGET_SSE2 && TARGET_SSE_MATH)
    && !COMMUTATIVE_ARITH_P (operands[3])
    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
   "* return output_387_binary_op (insn, operands);"

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]