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]

Re: [RFC & patch]: Fix PR27277


Ian Lance Taylor wrote:

Standard i387 constant load instructions (fldz, fld1, ...) are not
generated anymore with latest gcc, even for simple testcases like:


I can't see why it is correct to change the target independent code
here. This seems like something that should be handled in the target
costs.


...

In particular, a FLOAT_EXTEND of a magic constant like 0.0 would seem
to be more expensive than a SET of that same constant, and the i386
backend should reflect that.



Thanks to your comments! In attached patch revision, the problem is solved in the i386 RTX cost function, taking into account -Os compile flag and CPU types that benefit from standard constant load instructions (on i386 for example, loading SFmode "1.0" from memory is faster (20 cycles) than fld1 (24 cycles). The patch raises the cost of FLOAT_EXTEND for standard constants, so the cost is always higher than a simple SET, used in compress_float_constant() as a baseline.

A fldz is faster in all cases.

The patch is bootstrapped on x86_64-pc-linux-gnu, full regtest is currently in progress.

2006-05-04 Uros Bizjak <uros@kss-loka.si>

       PR target/27277
       * i386.c (ix86_rtx_costs) [FLOAT_EXTEND]: For standard 80387
       constants, raise the cost to prevent compress_float_constant()
       to generate load from memory.

Uros.
Index: i386.c
===================================================================
--- i386.c	(revision 113530)
+++ i386.c	(working copy)
@@ -17099,7 +17099,22 @@
       if (!TARGET_SSE_MATH
 	  || mode == XFmode
 	  || (mode == DFmode && !TARGET_SSE2))
-	*total = 0;
+	/* For standard 80387 constants, raise the cost to prevent
+	   compress_float_constant() to generate load from memory.  */
+	switch (standard_80387_constant_p (XEXP (x, 0)))
+	  {
+	  case -1:
+	  case 0:
+	    *total = 0;
+	    break;
+	  case 1: /* 0.0 */
+	    *total = 1;
+	    break;
+	  default:
+	    *total = (x86_ext_80387_constants & TUNEMASK
+		      || optimize_size
+		      ? 1 : 0);
+	  }
       return false;
 
     case ABS:

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