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]

Re: [New patch] x87 FLDx


Hi!

This time the values are precomputed. I hope this time it is ok.

Daniel


*** i386-protos.h.old	Tue Oct 23 02:01:59 2001
--- i386-protos.h	Mon Oct 22 16:25:45 2001
*************** extern void ix86_output_addr_diff_elt PA
*** 43,48 ****
--- 43,49 ----
  extern int ix86_aligned_p PARAMS ((rtx));

  extern int standard_80387_constant_p PARAMS ((rtx));
+ extern const char *output_standard_80387_constant_p PARAMS ((rtx));
  extern int standard_sse_constant_p PARAMS ((rtx));
  extern int symbolic_reference_mentioned_p PARAMS ((rtx));

*** i386.c.old	Tue Oct 23 12:23:39 2001
--- i386.c	Tue Oct 23 12:29:59 2001
*************** const int x86_memory_mismatch_stall = m_
*** 375,380 ****
--- 375,381 ----
  const int x86_accumulate_outgoing_args = m_ATHLON | m_PENT4 | m_PPRO;
  const int x86_prologue_using_move = m_ATHLON | m_PENT4 | m_PPRO;
  const int x86_epilogue_using_move = m_ATHLON | m_PENT4 | m_PPRO;
+ const int x86_ext_387_constant = m_PPRO | m_K6 | m_ATHLON | m_PENT4;
  
  /* In case the avreage insn count for single function invocation is
     lower than this constant, emit fast (but longer) prologue and
*************** static rtx construct_container PARAMS ((
*** 731,736 ****
--- 732,741 ----
  static enum x86_64_reg_class merge_classes PARAMS ((enum x86_64_reg_class,
  						    enum x86_64_reg_class));
  
+ static void init_ext_387_constant PARAMS ((void));
+ int init_x86_ext_387_constant = 1;
+ REAL_VALUE_TYPE x86_ext_387_constant_p[2][5];
+ 
  /* Initialize the GCC target structure.  */
  #undef TARGET_ATTRIBUTE_TABLE
  #define TARGET_ATTRIBUTE_TABLE ix86_attribute_table
*************** int
*** 3309,3326 ****
  standard_80387_constant_p (x)
       rtx x;
  {
!   if (GET_CODE (x) != CONST_DOUBLE || !FLOAT_MODE_P (GET_MODE (x)))
!     return -1;
!   /* Note that on the 80387, other constants, such as pi, that we should 
support
!      too.  On some machines, these are much slower to load as standard 
constant,
!      than to load from doubles in memory.  */
!   if (x == CONST0_RTX (GET_MODE (x)))
!     return 1;
!   if (x == CONST1_RTX (GET_MODE (x)))
!     return 2;
    return 0;
  }

  /* Return 1 if X is FP constant we can load to SSE register w/o using 
memory.
   */
  int
--- 3314,3399 ----
  standard_80387_constant_p (x)
       rtx x;
  {
!   if (GET_CODE (x) != CONST_DOUBLE || !FLOAT_MODE_P (GET_MODE (x))) return 
-1;
!   if (x == CONST0_RTX (GET_MODE (x))) return 1;
!   if (x == CONST1_RTX (GET_MODE (x))) return 2;
!   if (x86_ext_387_constant & CPUMASK)
!     {
!       if (init_x86_ext_387_constant) init_ext_387_constant();
!       if (GET_MODE (x) == SFmode)
! 	{
! 	  if (memcmp(&x86_ext_387_constant_p[0][0], &CONST_DOUBLE_LOW (x), sizeof 
(REAL_VALUE_TYPE)) == 0) return 3;
! 	  if (memcmp(&x86_ext_387_constant_p[0][1], &CONST_DOUBLE_LOW (x), sizeof 
(REAL_VALUE_TYPE)) == 0) return 4;
! 	  if (memcmp(&x86_ext_387_constant_p[0][2], &CONST_DOUBLE_LOW (x), sizeof 
(REAL_VALUE_TYPE)) == 0) return 5;
! 	  if (memcmp(&x86_ext_387_constant_p[0][3], &CONST_DOUBLE_LOW (x), sizeof 
(REAL_VALUE_TYPE)) == 0) return 6;
! 	  if (memcmp(&x86_ext_387_constant_p[0][4], &CONST_DOUBLE_LOW (x), sizeof 
(REAL_VALUE_TYPE)) == 0) return 7;
! 	}
!       else
! 	{
! 	  if (GET_MODE (x) == DFmode)
! 	    {
! 	      if (memcmp(&x86_ext_387_constant_p[1][0], &CONST_DOUBLE_LOW (x), 
sizeof (REAL_VALUE_TYPE)) == 0) return 3;
! 	      if (memcmp(&x86_ext_387_constant_p[1][1], &CONST_DOUBLE_LOW (x), 
sizeof (REAL_VALUE_TYPE)) == 0) return 4;
! 	      if (memcmp(&x86_ext_387_constant_p[1][2], &CONST_DOUBLE_LOW (x), 
sizeof (REAL_VALUE_TYPE)) == 0) return 5;
! 	      if (memcmp(&x86_ext_387_constant_p[1][3], &CONST_DOUBLE_LOW (x), 
sizeof (REAL_VALUE_TYPE)) == 0) return 6;
! 	      if (memcmp(&x86_ext_387_constant_p[1][4], &CONST_DOUBLE_LOW (x), 
sizeof (REAL_VALUE_TYPE)) == 0) return 7;
! 	    }
! 	}
!     }
    return 0;
  }

+ const char *
+ output_standard_80387_constant_p (x)
+      rtx x;
+ {
+   if (GET_CODE (x) != CONST_DOUBLE || !FLOAT_MODE_P (GET_MODE (x))) abort();
+   if (x == CONST0_RTX (GET_MODE (x))) return "fldz";
+   if (x == CONST1_RTX (GET_MODE (x))) return "fld1";
+   if (x86_ext_387_constant & CPUMASK)
+     {
+       if (init_x86_ext_387_constant) init_ext_387_constant();
+       if (GET_MODE (x) == SFmode)
+ 	{
+ 	  if (memcmp(&x86_ext_387_constant_p[0][0], &CONST_DOUBLE_LOW (x), sizeof 
(REAL_VALUE_TYPE)) == 0) return "fldlg2";
+ 	  if (memcmp(&x86_ext_387_constant_p[0][1], &CONST_DOUBLE_LOW (x), sizeof 
(REAL_VALUE_TYPE)) == 0) return "fldln2";
+ 	  if (memcmp(&x86_ext_387_constant_p[0][2], &CONST_DOUBLE_LOW (x), sizeof 
(REAL_VALUE_TYPE)) == 0) return "fldl2e";
+ 	  if (memcmp(&x86_ext_387_constant_p[0][3], &CONST_DOUBLE_LOW (x), sizeof 
(REAL_VALUE_TYPE)) == 0) return "fldl2t";
+ 	  if (memcmp(&x86_ext_387_constant_p[0][4], &CONST_DOUBLE_LOW (x), sizeof 
(REAL_VALUE_TYPE)) == 0) return "fldpi";
+ 	}
+       else
+         {
+ 	  if (GET_MODE (x) == DFmode)
+ 	    {
+ 	      if (memcmp(&x86_ext_387_constant_p[1][0], &CONST_DOUBLE_LOW (x), 
sizeof (REAL_VALUE_TYPE)) == 0) return "fldlg2";
+ 	      if (memcmp(&x86_ext_387_constant_p[1][1], &CONST_DOUBLE_LOW (x), 
sizeof (REAL_VALUE_TYPE)) == 0) return "fldln2";
+ 	      if (memcmp(&x86_ext_387_constant_p[1][2], &CONST_DOUBLE_LOW (x), 
sizeof (REAL_VALUE_TYPE)) == 0) return "fldl2e";
+ 	      if (memcmp(&x86_ext_387_constant_p[1][3], &CONST_DOUBLE_LOW (x), 
sizeof (REAL_VALUE_TYPE)) == 0) return "fldl2t";
+ 	      if (memcmp(&x86_ext_387_constant_p[1][4], &CONST_DOUBLE_LOW (x), 
sizeof (REAL_VALUE_TYPE)) == 0) return "fldpi";
+ 	    }
+ 	}
+     }
+   abort();
+ }
+ 
+ static void
+ init_ext_387_constant ()
+ {
+   x86_ext_387_constant_p[0][0] = REAL_VALUE_ATOF("0.301029995663981195", 
SFmode);
+   x86_ext_387_constant_p[0][1] = REAL_VALUE_ATOF("0.693147180559945309", 
SFmode);
+   x86_ext_387_constant_p[0][2] = REAL_VALUE_ATOF("1.442695040888963410", 
SFmode);
+   x86_ext_387_constant_p[0][3] = REAL_VALUE_ATOF("3.321928094887362350", 
SFmode);
+   x86_ext_387_constant_p[0][4] = REAL_VALUE_ATOF("3.141592653589793240", 
SFmode);
+
+   x86_ext_387_constant_p[1][0] = REAL_VALUE_ATOF("0.301029995663981195", 
DFmode);
+   x86_ext_387_constant_p[1][1] = REAL_VALUE_ATOF("0.693147180559945309", 
DFmode);
+   x86_ext_387_constant_p[1][2] = REAL_VALUE_ATOF("1.442695040888963410", 
DFmode);
+   x86_ext_387_constant_p[1][3] = REAL_VALUE_ATOF("3.321928094887362350", 
DFmode);
+   x86_ext_387_constant_p[1][4] = REAL_VALUE_ATOF("3.141592653589793240", 
DFmode);
+
+   init_x86_ext_387_constant = 0;
+ }
+
  /* Return 1 if X is FP constant we can load to SSE register w/o using 
memory.
   */
  int

*** i386.h.old	Tue Oct 23 02:02:00 2001
--- i386.h	Tue Oct 23 12:16:53 2001
*************** while (0)
*** 2444,2450 ****
  								\
        code = standard_80387_constant_p (RTX);			\
        return code == 1 ? 1 :					\
! 	     code == 2 ? 2 :					\
  			 3;					\
      }
  
--- 2444,2450 ----
  								\
        code = standard_80387_constant_p (RTX);			\
        return code == 1 ? 1 :					\
! 	     code >= 2 ? 2 :					\
  			 3;					\
      }

*** i386.md.old	Tue Oct 23 02:02:08 2001
--- i386.md	Tue Oct 23 12:16:26 2001
***************
*** 2740,2754 ****
        else
          return "fst%z0\t%y0";
  
!     case 2:
!       switch (standard_80387_constant_p (operands[1]))
!         {
!         case 1:
! 	  return "fldz";
! 	case 2:
! 	  return "fld1";
! 	}
!       abort();

      case 3:
      case 4:
--- 2740,2746 ----
        else
          return "fst%z0\t%y0";
  
!     case 2: return output_standard_80387_constant_p (operands[1]);
  
      case 3:
      case 4:
***************
*** 2915,2929 ****
        else
          return "fst%z0\t%y0";

!     case 2:
!       switch (standard_80387_constant_p (operands[1]))
!         {
!         case 1:
! 	  return "fldz";
! 	case 2:
! 	  return "fld1";
! 	}
!       abort();
  
      case 3:
      case 4:
--- 2907,2913 ----
        else
          return "fst%z0\t%y0";
  
!     case 2: return output_standard_80387_constant_p (operands[1]);

      case 3:
      case 4:
***************
*** 2972,2986 ****
        else
          return "fst%z0\t%y0";

!     case 2:
!       switch (standard_80387_constant_p (operands[1]))
!         {
!         case 1:
! 	  return "fldz";
! 	case 2:
! 	  return "fld1";
! 	}
!       abort();
  
      case 3:
      case 4:
--- 2956,2962 ----
        else
          return "fst%z0\t%y0";
  
!     case 2: return output_standard_80387_constant_p (operands[1]);
  
      case 3:
      case 4:
***************
*** 3230,3244 ****
        else
          return "fstp%z0\t%y0";
  
!     case 2:
!       switch (standard_80387_constant_p (operands[1]))
!         {
!         case 1:
! 	  return "fldz";
! 	case 2:
! 	  return "fld1";
! 	}
!       break;
  
      case 3: case 4:
        return "#";
--- 3206,3212 ----
        else
          return "fstp%z0\t%y0";
  
!     case 2: return output_standard_80387_constant_p (operands[1]);
  
      case 3: case 4:
        return "#";
***************
*** 3276,3290 ****
        else
          return "fstp%z0\t%y0";

!     case 2:
!       switch (standard_80387_constant_p (operands[1]))
!         {
!         case 1:
! 	  return "fldz";
! 	case 2:
! 	  return "fld1";
! 	}
!       break;

      case 3: case 4:
        return "#";
--- 3244,3250 ----
        else
          return "fstp%z0\t%y0";

!     case 2: return output_standard_80387_constant_p (operands[1]);

      case 3: case 4:
        return "#";
***************
*** 3323,3337 ****
        else
          return "fstp%z0\t%y0";
  
!     case 2:
!       switch (standard_80387_constant_p (operands[1]))
!         {
!         case 1:
! 	  return "fldz";
! 	case 2:
! 	  return "fld1";
! 	}
!       break;
  
      case 3: case 4:
        return "#";
--- 3283,3289 ----
        else
          return "fstp%z0\t%y0";
  
!     case 2: return output_standard_80387_constant_p (operands[1]);
  
      case 3: case 4:
        return "#";
***************
*** 3369,3383 ****
        else
          return "fstp%z0\t%y0";

!     case 2:
!       switch (standard_80387_constant_p (operands[1]))
!         {
!         case 1:
! 	  return "fldz";
! 	case 2:
! 	  return "fld1";
! 	}
!       break;

      case 3: case 4:
        return "#";
--- 3321,3327 ----
        else
          return "fstp%z0\t%y0";

!     case 2: return output_standard_80387_constant_p (operands[1]);

      case 3: case 4:
        return "#";


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