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]

[PATCH] Consider ffreep to pop TOS after f[u]compip


The following patch tweaks the i386 backend to use the ffreep
instruction to pop the x87 top of stack in output_fp_compare.
Unfortunately documentation of the ffreep insn is scarce, but
I assume that like fstp it preserves eflags, Jan?

I came across this whilst I was investigating adding GCC support to
reg-stack to use the "fcompp" instruction to discard the top two
values from the x87 stack (rather than use two fstp/ffreep insns).
If any x86 backend gurus have any preferences on how best to
represent this I'd be very interested.  I see Jan proposed a
related tweak to change_stack back in 1999 that was never reviewed.
http://gcc.gnu.org/ml/gcc-patches/1999-10n/msg00826.html


The following patch has been tested on i686-pc-linux-gnu with a
full "make bootstrap", all current languages, and regression
tested with a top-level "make -k check" with no new failures.

Ok for mainline?


2004-05-16  Roger Sayle  <roger@eyesopen.com>

	* config/i386/i386.c (output_fp_compare): Use ffreep to pop top
	value off of the stack if TARGET_USE_FFREEP.


Index: config/i386/i386.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.c,v
retrieving revision 1.667
diff -c -3 -p -r1.667 i386.c
*** config/i386/i386.c	7 May 2004 14:29:41 -0000	1.667
--- config/i386/i386.c	16 May 2004 02:20:43 -0000
*************** output_fp_compare (rtx insn, rtx *operan
*** 8183,8189 ****
  	    output_asm_insn ("fucomip\t{%y1, %0|%0, %y1}", operands);
  	  else
  	    output_asm_insn ("fcomip\t{%y1, %0|%0, %y1}", operands);
! 	  return "fstp\t%y0";
  	}
        else
  	{
--- 8183,8189 ----
  	    output_asm_insn ("fucomip\t{%y1, %0|%0, %y1}", operands);
  	  else
  	    output_asm_insn ("fcomip\t{%y1, %0|%0, %y1}", operands);
! 	  return TARGET_USE_FFREEP ? "ffreep\t%y0" : "fstp\t%y0";
  	}
        else
  	{


Roger
--


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