expr.c (compress_float_constant): Add cost check.
authorDale Johannesen <dalej@apple.com>
Tue, 12 Jul 2005 20:29:51 +0000 (20:29 +0000)
committerDale Johannesen <dalej@gcc.gnu.org>
Tue, 12 Jul 2005 20:29:51 +0000 (20:29 +0000)
2005-07-12  Dale Johannesen  <dalej@apple.com>

        * expr.c (compress_float_constant):  Add cost check.
        * config/rs6000.c (rs6000_rtx_cost):  Adjust FLOAT_EXTEND cost.

From-SVN: r101938

gcc/ChangeLog
gcc/config/rs6000/rs6000.c
gcc/expr.c

index 731f4af1a90c3bd99e37677bebdd56ffef689506..30269f96f6779017003640bb24f3ab1ac54d0771 100644 (file)
@@ -1,3 +1,17 @@
+2005-07-12  Dale Johannesen  <dalej@apple.com>
+
+       * expr.c (compress_float_constant):  Add cost check.
+       * config/rs6000.c (rs6000_rtx_cost):  Adjust FLOAT_EXTEND cost.
+
+2005-07-12  Dale Johannesen  <dalej@apple.com>
+
+       * gcc.target/i386/compress-float-sse.c:  New.
+       * gcc.target/i386/compress-float-sse-pic.c:  New.
+       * gcc.target/i386/compress-float-387.c:  New.
+       * gcc.target/i386/compress-float-387-pic.c:  New.
+       * gcc.dg/compress-float-ppc.c:  New.
+       * gcc.dg/compress-float-ppc-pic.c:  New.
+
 2005-07-12  Eric Christopher  <echristo@redhat.com>
 
        * gcc.c (struct infile): Update comment for language.
index 921d16ff78333068fcfbc01dd1aa446eee14a85b..4cf8dd876e3b1f3a462ad8e910640b6b9e6410de 100644 (file)
@@ -18043,11 +18043,17 @@ rs6000_rtx_costs (rtx x, int code, int outer_code, int *total)
        }
       /* FALLTHRU */
 
+    case FLOAT_EXTEND:
+      if (mode == DFmode)
+       *total = 0;
+      else
+       *total = rs6000_cost->fp;
+      return false;
+
     case FLOAT:
     case UNSIGNED_FLOAT:
     case FIX:
     case UNSIGNED_FIX:
-    case FLOAT_EXTEND:
     case FLOAT_TRUNCATE:
       *total = rs6000_cost->fp;
       return false;
index 01f890fa6a51eb9100cb99b593bfe26cd95e482f..182ab2382be172d9e23b31ced052045c395076fb 100644 (file)
@@ -3202,9 +3202,15 @@ compress_float_constant (rtx x, rtx y)
   enum machine_mode orig_srcmode = GET_MODE (y);
   enum machine_mode srcmode;
   REAL_VALUE_TYPE r;
+  int oldcost, newcost;
 
   REAL_VALUE_FROM_CONST_DOUBLE (r, y);
 
+  if (LEGITIMATE_CONSTANT_P (y))
+    oldcost = rtx_cost (y, SET);
+  else
+    oldcost = rtx_cost (force_const_mem (dstmode, y), SET);
+
   for (srcmode = GET_CLASS_NARROWEST_MODE (GET_MODE_CLASS (orig_srcmode));
        srcmode != orig_srcmode;
        srcmode = GET_MODE_WIDER_MODE (srcmode))
@@ -3229,12 +3235,23 @@ compress_float_constant (rtx x, rtx y)
             the extension.  */
          if (! (*insn_data[ic].operand[1].predicate) (trunc_y, srcmode))
            continue;
+         /* This is valid, but may not be cheaper than the original. */
+         newcost = rtx_cost (gen_rtx_FLOAT_EXTEND (dstmode, trunc_y), SET);
+         if (oldcost < newcost)
+           continue;
        }
       else if (float_extend_from_mem[dstmode][srcmode])
-       trunc_y = validize_mem (force_const_mem (srcmode, trunc_y));
+       {
+         trunc_y = force_const_mem (srcmode, trunc_y);
+         /* This is valid, but may not be cheaper than the original. */
+         newcost = rtx_cost (gen_rtx_FLOAT_EXTEND (dstmode, trunc_y), SET);
+         if (oldcost < newcost)
+           continue;
+         trunc_y = validize_mem (trunc_y);
+       }
       else
        continue;
-
       emit_unop_insn (ic, x, trunc_y, UNKNOWN);
       last_insn = get_last_insn ();