This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[New patch] x87 FLDx
- To: gcc-patches at gcc dot gnu dot org
- Subject: [New patch] x87 FLDx
- From: Daniel Jungmann <D-S-J at web dot de>
- Date: Sat, 20 Oct 2001 12:17:44 +0200
Hi!
I hope that this time the patch is better. It adds the fldlg2, fldln2,
fldl2e, fld2t and fldpi instructions, because they have the same latency like
the fld1 instruction on an k7, k6, ppro, p3 and p4.
Daniel
*** i386-protos.h.old Sat Oct 20 04:34:52 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 Sat Oct 20 04:34:52 2001
--- i386.c Sat Oct 20 10:49:33 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
*************** int
*** 3316,3331 ****
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.
--- 3317,3352 ----
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 (x == CONST_DOUBLE_FROM_REAL_VALUE
(REAL_VALUE_ATOF("0.301029995663981195", GET_MODE (x)), GET_MODE (x))) return
3;
! if (x == CONST_DOUBLE_FROM_REAL_VALUE
(REAL_VALUE_ATOF("0.693147180559945309", GET_MODE (x)), GET_MODE (x))) return
4;
! if (x == CONST_DOUBLE_FROM_REAL_VALUE
(REAL_VALUE_ATOF("1.442695040888963410", GET_MODE (x)), GET_MODE (x))) return
5;
! if (x == CONST_DOUBLE_FROM_REAL_VALUE
(REAL_VALUE_ATOF("3.321928094887362350", GET_MODE (x)), GET_MODE (x))) return
6;
! if (x == CONST_DOUBLE_FROM_REAL_VALUE
(REAL_VALUE_ATOF("3.141592653589793240", GET_MODE (x)), GET_MODE (x))) 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 (x == CONST_DOUBLE_FROM_REAL_VALUE
(REAL_VALUE_ATOF("0.301029995663981195", GET_MODE (x)), GET_MODE (x))) return
"fldlg2";
+ if (x == CONST_DOUBLE_FROM_REAL_VALUE
(REAL_VALUE_ATOF("0.693147180559945309", GET_MODE (x)), GET_MODE (x))) return
"fldln2";
+ if (x == CONST_DOUBLE_FROM_REAL_VALUE
(REAL_VALUE_ATOF("1.442695040888963410", GET_MODE (x)), GET_MODE (x))) return
"fldl2e";
+ if (x == CONST_DOUBLE_FROM_REAL_VALUE
(REAL_VALUE_ATOF("3.321928094887362350", GET_MODE (x)), GET_MODE (x))) return
"fldl2t";
+ if (x == CONST_DOUBLE_FROM_REAL_VALUE
(REAL_VALUE_ATOF("3.141592653589793240", GET_MODE (x)), GET_MODE (x))) return
"fldpi";
+ }
+ abort();
}
/* Return 1 if X is FP constant we can load to SSE register w/o using
memory.
*** i386.md.old Sat Oct 20 04:34:54 2001
--- i386.md Sat Oct 20 10:52:12 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 "#";