i386.h (struct_processor_costs): New fileds int_load, int_store, fp_move, fp_load...
authorJan Hubicka <hubicka@freesoft.cz>
Fri, 19 Nov 1999 09:12:18 +0000 (09:12 +0000)
committerJan Hubicka <hubicka@gcc.gnu.org>
Fri, 19 Nov 1999 09:12:18 +0000 (09:12 +0000)
* i386.h (struct_processor_costs): New fileds int_load, int_store, fp_move,
fp_load and fp_store
(REGISTER_MOVE_COST): Fix comment, calculate exactly the cost of
fp->int moves
(MEMORY_MOVE_COST): New macro.
* i386.c (386_cost): Define new fields.
(i486_cost): Likewise.
(pentium_cost): Likewise.
(pentiumpro_cost): Likewise.
(k6_cost): Likewise.

From-SVN: r30585

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

index f5f41250dd1ec7ca8797fda565d0160d8c7824db..46c575bfdddd6a495db2760976dfa99fe4744c8f 100644 (file)
@@ -1,3 +1,15 @@
+Fri Nov 18 13:39:22 CET 1999  Jam Hubicka  <hubicka@freesoft.cz>
+       * i386.h (struct_processor_costs): New fileds int_load, int_store, fp_move,
+       fp_load and fp_store
+       (REGISTER_MOVE_COST): Fix comment, calculate exactly the cost of
+       fp->int moves
+       (MEMORY_MOVE_COST): New macro.
+       * i386.c (386_cost): Define new fields.
+       (i486_cost): Likewise.
+       (pentium_cost): Likewise.
+       (pentiumpro_cost): Likewise.
+       (k6_cost): Likewise.
+
 Fri Nov 19 11:11:55 1999  Greg McGary  <gkm@gnu.org>
                          Geoffrey Keating  <geoffk@cygnus.com>
 
index c8e89954be84b4c35c7fe2ab791a11cbae0be9a3..4707ebff9e953b758dc97a7b2a65349b511096c1 100644 (file)
@@ -63,7 +63,15 @@ struct processor_costs i386_cost = { /* 386 specific costs */
   6,                                   /* cost of starting a multiply */
   1,                                   /* cost of multiply per each bit set */
   23,                                  /* cost of a divide/mod */
-  15                                   /* "large" insn */
+  15,                                  /* "large" insn */
+  {2, 4, 2},                           /* cost of loading integer registers
+                                          in QImode, HImode and SImode.
+                                          Relative to reg-reg move (2). */
+  {2, 4, 2},                           /* cost of storing integer registers */
+  2,                                   /* cost of reg,reg fld/fst */
+  {8, 8, 8},                           /* cost of loading fp registers
+                                          in SFmode, DFmode and XFmode */
+  {8, 8, 8}                            /* cost of loading integer registers */
 };
 
 struct processor_costs i486_cost = {   /* 486 specific costs */
@@ -74,7 +82,15 @@ struct processor_costs i486_cost = { /* 486 specific costs */
   12,                                  /* cost of starting a multiply */
   1,                                   /* cost of multiply per each bit set */
   40,                                  /* cost of a divide/mod */
-  15                                   /* "large" insn */
+  15,                                  /* "large" insn */
+  {2, 4, 2},                           /* cost of loading integer registers
+                                          in QImode, HImode and SImode.
+                                          Relative to reg-reg move (2). */
+  {2, 4, 2},                           /* cost of storing integer registers */
+  2,                                   /* cost of reg,reg fld/fst */
+  {8, 8, 8},                           /* cost of loading fp registers
+                                          in SFmode, DFmode and XFmode */
+  {8, 8, 8}                            /* cost of loading integer registers */
 };
 
 struct processor_costs pentium_cost = {
@@ -85,7 +101,15 @@ struct processor_costs pentium_cost = {
   11,                                  /* cost of starting a multiply */
   0,                                   /* cost of multiply per each bit set */
   25,                                  /* cost of a divide/mod */
-  8                                    /* "large" insn */
+  8,                                   /* "large" insn */
+  {2, 4, 2},                           /* cost of loading integer registers
+                                          in QImode, HImode and SImode.
+                                          Relative to reg-reg move (2). */
+  {2, 4, 2},                           /* cost of storing integer registers */
+  2,                                   /* cost of reg,reg fld/fst */
+  {2, 2, 6},                           /* cost of loading fp registers
+                                          in SFmode, DFmode and XFmode */
+  {4, 4, 6}                            /* cost of loading integer registers */
 };
 
 struct processor_costs pentiumpro_cost = {
@@ -96,7 +120,15 @@ struct processor_costs pentiumpro_cost = {
   1,                                   /* cost of starting a multiply */
   0,                                   /* cost of multiply per each bit set */
   17,                                  /* cost of a divide/mod */
-  8                                    /* "large" insn */
+  8,                                   /* "large" insn */
+  {4, 4, 4},                           /* cost of loading integer registers
+                                          in QImode, HImode and SImode.
+                                          Relative to reg-reg move (2). */
+  {2, 2, 2},                           /* cost of storing integer registers */
+  2,                                   /* cost of reg,reg fld/fst */
+  {2, 2, 6},                           /* cost of loading fp registers
+                                          in SFmode, DFmode and XFmode */
+  {4, 4, 6}                            /* cost of loading integer registers */
 };
 
 struct processor_costs k6_cost = {
@@ -107,7 +139,15 @@ struct processor_costs k6_cost = {
   3,                                   /* cost of starting a multiply */
   0,                                   /* cost of multiply per each bit set */
   18,                                  /* cost of a divide/mod */
-  8                                    /* "large" insn */
+  8,                                   /* "large" insn */
+  {4, 5, 4},                           /* cost of loading integer registers
+                                          in QImode, HImode and SImode.
+                                          Relative to reg-reg move (2). */
+  {2, 3, 2},                           /* cost of storing integer registers */
+  4,                                   /* cost of reg,reg fld/fst */
+  {6, 6, 6},                           /* cost of loading fp registers
+                                          in SFmode, DFmode and XFmode */
+  {4, 4, 4}                            /* cost of loading integer registers */
 };
 
 struct processor_costs *ix86_cost = &pentium_cost;
index ad52760cf38516d4b818505f67b02e0bbf13f369..ee2b51f5a5112d86b6f2c29ad5b4f34c54247a33 100644 (file)
@@ -62,6 +62,16 @@ struct processor_costs {
   int mult_bit;                        /* cost of multiply per each bit set */
   int divide;                  /* cost of a divide/mod */
   int large_insn;              /* insns larger than this cost more */
+  int int_load[3];             /* cost of loading integer registers
+                                  in QImode, HImode and SImode relative
+                                  to reg-reg move (2).  */
+  int int_store[3];            /* cost of storing integer register
+                                  in QImode, HImode and SImode */
+  int fp_move;                 /* cost of reg,reg fld/fst */
+  int fp_load[3];              /* cost of loading FP register
+                                  in SFmode, DFmode and XFmode */
+  int fp_store[3];             /* cost of storing FP register
+                                  in SFmode, DFmode and XFmode */
 };
 
 extern struct processor_costs *ix86_cost;
@@ -1956,22 +1966,28 @@ while (0)
    : REG_P (RTX) ? 1                                           \
    : 2)
 
-/* A C expression for the cost of moving data of mode M between a
-   register and memory.  A value of 2 is the default; this cost is
-   relative to those in `REGISTER_MOVE_COST'.
+/* A C expression for the cost of moving data from a register in class FROM to
+   one in class TO.  The classes are expressed using the enumeration values
+   such as `GENERAL_REGS'.  A value of 2 is the default; other values are
+   interpreted relative to that.
 
-   If moving between registers and memory is more expensive than
-   between two registers, you should define this macro to express the
-   relative cost.
+   It is not required that the cost always equal 2 when FROM is the same as TO;
+   on some machines it is expensive to move between registers if they are not
+   general registers.
 
    On the i386, copying between floating-point and fixed-point
-   registers is expensive.  */
+   registers is done trough memory.  
+   Integer -> fp moves are noticeably slower than the opposite direction
+   because of the partial memory stall they cause.  Give it an
+   arbitary high cost.
+ */
 
 #define REGISTER_MOVE_COST(CLASS1, CLASS2)                             \
-  (((FLOAT_CLASS_P (CLASS1) && ! FLOAT_CLASS_P (CLASS2))               \
-    || (! FLOAT_CLASS_P (CLASS1) && FLOAT_CLASS_P (CLASS2))) ? 10      \
-   : 2)
-
+  ((FLOAT_CLASS_P (CLASS1) && ! FLOAT_CLASS_P (CLASS2))                        \
+   ? (MEMORY_MOVE_COST (DFmode, CLASS1, 0)                             \
+     + MEMORY_MOVE_COST (DFmode, CLASS2, 1))                           \
+   : (! FLOAT_CLASS_P (CLASS1) && FLOAT_CLASS_P (CLASS2)) ? 10 : 2)
 
 /* A C expression for the cost of moving data of mode M between a
    register and memory.  A value of 2 is the default; this cost is
@@ -1981,7 +1997,19 @@ while (0)
    between two registers, you should define this macro to express the
    relative cost.  */
 
-/* #define MEMORY_MOVE_COST(M,C,I) 2  */
+#define MEMORY_MOVE_COST(MODE,CLASS,IN)                                        \
+  (FLOAT_CLASS_P (CLASS)                                               \
+   ? (GET_MODE_SIZE (MODE)==4                                          \
+      ? (IN ? ix86_cost->fp_load[0] : ix86_cost->fp_store[0])          \
+      : (GET_MODE_SIZE (MODE)==8                                       \
+        ? (IN ? ix86_cost->fp_load[1] : ix86_cost->fp_store[1])        \
+        : (IN ? ix86_cost->fp_load[2] : ix86_cost->fp_store[2])))      \
+   : (GET_MODE_SIZE (MODE)==1                                          \
+      ? (IN ? ix86_cost->int_load[0] : ix86_cost->int_store[0])                \
+      : (GET_MODE_SIZE (MODE)==2                                       \
+        ? (IN ? ix86_cost->int_load[1] : ix86_cost->int_store[1])      \
+        : ((IN ? ix86_cost->int_load[2] : ix86_cost->int_store[2])     \
+           * GET_MODE_SIZE (MODE) / 4))))
 
 /* A C expression for the cost of a branch instruction.  A value of 1
    is the default; other values are interpreted relative to that.  */