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: [patch] x87 FLDx


Hi!

currently i386.md & i386.c just uses fldz and fld1, but the fldlg2, fldln2, 
fldl2e, fldl2t and fldpi instructions have the same latency like fld1 on an 
k6, k7, p4, p3 and ppro. The patch adds the fldlg2, fldln2, fldl2e, fldl2t 
and fldpi instructions.

Daniel

*** i386-protos.h.old	Wed Oct 17 03:39:46 2001
--- i386-protos.h	Thu Oct 18 23:18:12 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	Thu Oct 18 22:59:27 2001
--- i386.c	Fri Oct 19 01:49:25 2001
*************** Boston, MA 02111-1307, USA.  */
*** 42,47 ****
--- 42,48 ----
  #include "ggc.h"
  #include "target.h"
  #include "target-def.h"
+ #include "real.h"
  
  #ifndef CHECK_STACK_LIMIT
  #define CHECK_STACK_LIMIT -1
*************** aligned_operand (op, mode)
*** 3308,3314 ****
    /* Didn't find one -- this must be an aligned address.  */
    return 1;
  }
!  
  /* Return true if the constant is something that can be loaded with
     a special instruction.  Only handle 0.0 and 1.0; others are less
     worthwhile.  */
--- 3309,3315 ----
    /* Didn't find one -- this must be an aligned address.  */
    return 1;
  }
! 
  /* Return true if the constant is something that can be loaded with
     a special instruction.  Only handle 0.0 and 1.0; others are less
     worthwhile.  */
*************** int
*** 3317,3343 ****
  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;
!   return 0;
    if (x86_ext_387_constant & CPUMASK)
      {
!       unsigned long long d;
!       d = 0x3FD34413509F79FF;
!       if (memcmp(&d, &CONST_DOUBLE_LOW (x), sizeof d) == 0) return 3;
!       d = 0x3FE62E42FEFA39EF;
!       if (memcmp(&d, &CONST_DOUBLE_LOW (x), sizeof d) == 0) return 4;
!       d = 0x3FF71547652B82FE;
!       if (memcmp(&d, &CONST_DOUBLE_LOW (x), sizeof d) == 0) return 5;
!       d = 0x400A934F0979A371;
!       if (memcmp(&d, &CONST_DOUBLE_LOW (x), sizeof d) == 0) return 6;
!       d = 0x400921FB54442D18;
!       if (memcmp(&d, &CONST_DOUBLE_LOW (x), sizeof d) == 0) return 7;
!     }
    return 0;
  }
  
--- 3318,3350 ----
  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)
      {
!       enum machine_mode mode;
!       enum machine_mode double_mode;
!       union real_extract u;
!       double_mode = VOIDmode;
!       for (mode = GET_CLASS_NARROWEST_MODE (MODE_FLOAT); mode != VOIDmode;
!         mode = GET_MODE_WIDER_MODE (mode))
! 	{
! 	  if (GET_MODE_BITSIZE (mode) == DOUBLE_TYPE_SIZE
! 	    && double_mode == VOIDmode)
! 	    double_mode = mode;
! 	}
!       u.d = REAL_VALUE_ATOF ("0.301029995663981195", double_mode);
!       if (memcmp(&u, &CONST_DOUBLE_LOW (x), sizeof u) == 0) return 3;
!       u.d = REAL_VALUE_ATOF ("0.693147180559945309", double_mode);
!       if (memcmp(&u, &CONST_DOUBLE_LOW (x), sizeof u) == 0) return 4;
!       u.d = REAL_VALUE_ATOF ("1.442695040888963410", double_mode);
!       if (memcmp(&u, &CONST_DOUBLE_LOW (x), sizeof u) == 0) return 5;
!       u.d = REAL_VALUE_ATOF ("3.321928094887362350", double_mode);
!       if (memcmp(&u, &CONST_DOUBLE_LOW (x), sizeof u) == 0) return 6;
!       u.d = REAL_VALUE_ATOF ("3.141592653589793240", double_mode);
!       if (memcmp(&u, &CONST_DOUBLE_LOW (x), sizeof u) == 0) return 7;
!   }
    return 0;
  }
  
*************** const char *
*** 3345,3368 ****
  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)
      {
!       unsigned long long d;
!       d = 0x3FD34413509F79FF;
!       if (memcmp(&d, &CONST_DOUBLE_LOW (x), sizeof d) == 0) return "fldlg2";
!       d = 0x3FE62E42FEFA39EF;
!       if (memcmp(&d, &CONST_DOUBLE_LOW (x), sizeof d) == 0) return "fldln2";
!       d = 0x3FF71547652B82FE;
!       if (memcmp(&d, &CONST_DOUBLE_LOW (x), sizeof d) == 0) return "fldl2e";
!       d = 0x400A934F0979A371;
!       if (memcmp(&d, &CONST_DOUBLE_LOW (x), sizeof d) == 0) return "fldl2t";
!       d = 0x400921FB54442D18;
!       if (memcmp(&d, &CONST_DOUBLE_LOW (x), sizeof d) == 0) return "fldpi";
!     }
    abort();
  }
  
--- 3352,3384 ----
  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)
      {
!       enum machine_mode mode;
!       enum machine_mode double_mode;
!       union real_extract u;
!       double_mode = VOIDmode;
!       for (mode = GET_CLASS_NARROWEST_MODE (MODE_FLOAT); mode != VOIDmode;
!         mode = GET_MODE_WIDER_MODE (mode))
! 	{
! 	  if (GET_MODE_BITSIZE (mode) == DOUBLE_TYPE_SIZE
! 	    && double_mode == VOIDmode)
! 	    double_mode = mode;
! 	}
!       u.d = REAL_VALUE_ATOF ("0.301029995663981195", double_mode);
!       if (memcmp(&u, &CONST_DOUBLE_LOW (x), sizeof u) == 0) return "fldlg2";
!       u.d = REAL_VALUE_ATOF ("0.693147180559945309", double_mode);
!       if (memcmp(&u, &CONST_DOUBLE_LOW (x), sizeof u) == 0) return "fldln2";
!       u.d = REAL_VALUE_ATOF ("1.442695040888963410", double_mode);
!       if (memcmp(&u, &CONST_DOUBLE_LOW (x), sizeof u) == 0) return "fldl2e";
!       u.d = REAL_VALUE_ATOF ("3.321928094887362350", double_mode);
!       if (memcmp(&u, &CONST_DOUBLE_LOW (x), sizeof u) == 0) return "fldl2t";
!       u.d = REAL_VALUE_ATOF ("3.141592653589793240", double_mode);
!       if (memcmp(&u, &CONST_DOUBLE_LOW (x), sizeof u) == 0) return "fldpi";
!   }
    abort();
  }
  
*** i386.md.old	Wed Oct 17 03:39:46 2001
--- i386.md	Thu Oct 18 23:14:09 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:
***************
*** 2896,2902 ****
     && (optimize_size || !TARGET_INTEGER_DFMODE_MOVES)
     && (reload_in_progress || reload_completed
         || GET_CODE (operands[1]) != CONST_DOUBLE
!        || memory_operand (operands[0], DFmode))" 
  {
    switch (which_alternative)
      {
--- 2888,2894 ----
     && (optimize_size || !TARGET_INTEGER_DFMODE_MOVES)
     && (reload_in_progress || reload_completed
         || GET_CODE (operands[1]) != CONST_DOUBLE
!        || memory_operand (operands[0], DFmode))"
  {
    switch (which_alternative)
      {
***************
*** 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]