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]

[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 fldz or fld1 
on an k6, k7, p4, p3 and ppro. 

The patch adds this instructions to i386.md and i386.c

Daniel

--- i386.c Wed Oct 17 22:56:18 2001
************
*** 17, 48 ***

	#include "ggc.h"
	#include "target.h"
	#include "target-def.h"
+	#include "real.h"

	#ifndef CHECK_STACK_LIMIT
	#define CHECK_STACK_LIMIT -1
	#endif

*** 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
	   epilogue code.  */

*** 3324, 3332 ***

	  if (x == CONST0_RTX (GET_MODE (x)))
	    return 1;
	  if (x == CONST1_RTX (GET_MODE (x)))
	    return 2;
+	  if (x86_ext_387_constant & (1 << ix86_arch))
+	    {
+	      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.301029995663981", double_mode);
+	      if (memcmp(&u, &CONST_DOUBLE_LOW (x), sizeof u) == 0) return 3;
+	      u.d = REAL_VALUE_ATOF ("0.693147180559945", double_mode);
+	      if (memcmp(&u, &CONST_DOUBLE_LOW (x), sizeof u) == 0) return 4;
+	      u.d = REAL_VALUE_ATOF ("1.44269504088896", double_mode);
+	      if (memcmp(&u, &CONST_DOUBLE_LOW (x), sizeof u) == 0) return 5;
+	      u.d = REAL_VALUE_ATOF ("3.32192809488736", double_mode);
+	      if (memcmp(&u, &CONST_DOUBLE_LOW (x), sizeof u) == 0) return 6;
+	      u.d = REAL_VALUE_ATOF ("3.14159265358979", double_mode);
+	      if (memcmp(&u, &CONST_DOUBLE_LOW (x), sizeof u) == 0) return 7;
+	    }
	  return 0;
	}

/* Return 1 if X is FP constant we can load to SSE register w/o using memory.
 */

************
--- i386.md Wed Oct 17 22:56:18 2001
************
*** 2744, 2751 ***

	      switch (standard_80387_constant_p (operands[1]))
	        {
	        case 1:
		  return "fldz";
		case 2:
		  return "fld1";
+		case 3:
+		  return "fldlg2";
+		case 4:
+		  return "fldln2";
+		case 5:
+		  return "fldl2e";
+		case 6:
+		  return "fldl2t";
+		case 7:
+		  return "fldpi";
	        }
	      abort();

*** 2919, 2926 ***

	      switch (standard_80387_constant_p (operands[1]))
	        {
	        case 1:
		  return "fldz";
		case 2:
		  return "fld1";
+		case 3:
+		  return "fldlg2";
+		case 4:
+		  return "fldln2";
+		case 5:
+		  return "fldl2e";
+		case 6:
+		  return "fldl2t";
+		case 7:
+		  return "fldpi";
	        }
	      abort();

*** 2976, 2983 ***

	      switch (standard_80387_constant_p (operands[1]))
	        {
	        case 1:
		  return "fldz";
		case 2:
		  return "fld1";
+		case 3:
+		  return "fldlg2";
+		case 4:
+		  return "fldln2";
+		case 5:
+		  return "fldl2e";
+		case 6:
+		  return "fldl2t";
+		case 7:
+		  return "fldpi";
	        }
	      abort();

*** 3234, 3241 ***

	      switch (standard_80387_constant_p (operands[1]))
	        {
	        case 1:
		  return "fldz";
		case 2:
		  return "fld1";
+		case 3:
+		  return "fldlg2";
+		case 4:
+		  return "fldln2";
+		case 5:
+		  return "fldl2e";
+		case 6:
+		  return "fldl2t";
+		case 7:
+		  return "fldpi";
	        }
	      break;

*** 3280, 3287 ***

	      switch (standard_80387_constant_p (operands[1]))
	        {
	        case 1:
		  return "fldz";
		case 2:
		  return "fld1";
+		case 3:
+		  return "fldlg2";
+		case 4:
+		  return "fldln2";
+		case 5:
+		  return "fldl2e";
+		case 6:
+		  return "fldl2t";
+		case 7:
+		  return "fldpi";
	        }
	      break;

*** 3327, 3334 ***

	      switch (standard_80387_constant_p (operands[1]))
	        {
	        case 1:
		  return "fldz";
		case 2:
		  return "fld1";
+		case 3:
+		  return "fldlg2";
+		case 4:
+		  return "fldln2";
+		case 5:
+		  return "fldl2e";
+		case 6:
+		  return "fldl2t";
+		case 7:
+		  return "fldpi";
	        }
	      break;

*** 3373, 3384 ***

	      switch (standard_80387_constant_p (operands[1]))
	        {
	        case 1:
		  return "fldz";
		case 2:
		  return "fld1";
+		case 3:
+		  return "fldlg2";
+		case 4:
+		  return "fldln2";
+		case 5:
+		  return "fldl2e";
+		case 6:
+		  return "fldl2t";
+		case 7:
+		  return "fldpi";
	        }
	      break;


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