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]

REVERSIBE_CC_MODE and REVERSE_CONDITION for i386



Hi
This patch sets the REVERSIBLE_CC_MODE and REVERSE_CONDITION for i386 It also
cleanups the ix86_fp_compare_mode and documents the REVERSE_CONDITION, that is
functional now.

Honza

Bootstrapped and regression tested on i386 with and without -march=athlon

Pá led 12 18:07:56 CET 2001  Jan Hubicka  <jh@suse.cz>
	* tm.texi (REVERSE_CONDITION): Document.
	* i386.c (ix86_fp_compare_mode): Simplify; return always CCFPmode
	in -ffast-math mode.
	* i386.h (REVERSE_CONDITION, REVERSIBLE_CC_MODE): New macro.
*** ../../../../orig/egcs/gcc/config/i386/i386.c	Thu Jan 11 11:18:04 2001
--- i386.c	Fri Jan 12 17:30:40 2001
*************** enum machine_mode
*** 4647,4681 ****
  ix86_fp_compare_mode (code)
       enum rtx_code code;
  {
!   int unordered;
! 
!   switch (code)
!     {
!     case NE: case EQ:
!       /* When not doing IEEE compliant compares, fault on NaNs.  */
!       unordered = (TARGET_IEEE_FP != 0);
!       break;
! 
!     case LT: case LE: case GT: case GE:
!       unordered = 0;
!       break;
! 
!     case UNORDERED: case ORDERED:
!     case UNEQ: case UNGE: case UNGT: case UNLE: case UNLT: case LTGT:
!       unordered = 1;
!       break;
! 
!     default:
!       abort ();
!     }
! 
!   /* ??? If we knew whether invalid-operand exceptions were masked,
!      we could rely on fcom to raise an exception and take care of
!      NaNs.  But we don't.  We could know this from c99 math pragmas.  */
!   if (TARGET_IEEE_FP)
!     unordered = 1;
! 
!   return unordered ? CCFPUmode : CCFPmode;
  }
  
  enum machine_mode
--- 4653,4664 ----
  ix86_fp_compare_mode (code)
       enum rtx_code code;
  {
!   /* ??? In order to make all comparisons reversible, we do all comparisons
!      non-trapping when compiling for IEEE.  Once gcc is able to distinguish
!      all forms trapping and nontrapping comparisons, we can make inequality
!      comparisons trapping again, since it results in better code when using
!      FCOM based compares.  */
!   return TARGET_IEEE_FP ? CCFPUmode : CCFPmode;
  }
  
  enum machine_mode
*** ../../../../orig/egcs/gcc/config/i386/i386.h	Thu Jan 11 11:18:06 2001
--- i386.h	Fri Jan 12 18:01:54 2001
*************** while (0)
*** 2532,2537 ****
--- 2532,2549 ----
     possible, to allow for more combinations.  */
  
  #define SELECT_CC_MODE(OP,X,Y) ix86_cc_mode (OP, X, Y)
+ 
+ /* Return non-zero if MODE implies a floating point inequality can be
+    reversed.  */
+ 
+ #define REVERSIBLE_CC_MODE(MODE) 1
+ 
+ /* A C expression whose value is reversed condition code of the CODE for
+    comparison done in CC_MODE mode.  */
+ #define REVERSE_CONDITION(CODE, MODE) \
+   ((MODE) != CCFPmode && (MODE) != CCFPUmode ? reverse_condition (CODE) \
+    : reverse_condition_maybe_unordered (CODE))
+ 
  
  /* Control the assembler format that we output, to the extent
     this does not vary between assemblers.  */
*** tm.texi.old	Fri Jan 12 17:53:53 2001
--- tm.texi	Fri Jan 12 18:14:45 2001
*************** inequality comparisons are always given 
*** 4856,4861 ****
--- 4856,4876 ----
  #define REVERSIBLE_CC_MODE(MODE)  ((MODE) != CCFPEmode)
  @end smallexample
  
+ @findex REVERSE_CONDITION (@var{code}, @var{mode})
+ A C expression whose value is reversed condition code of the @var{code} for
+ comparison done in CC_MODE @var{mode}.  The macro is used only in case
+ @code{REVERSIBLE_CC_MODE (@var{mode})} is nonzero.  Define this macro in case
+ machine has some non-standard way how to reverse certain conditionals.  For
+ instance in case all floating point conditions are non-trapping, compiler may
+ freely convert unordered compares to ordered one.  Then definition may look
+ like:
+ 
+ @smallexample
+ #define REVERSE_CONDITION(CODE, MODE) \
+    ((MODE) != CCFPmode ? reverse_condtion (CODE) \
+     : reverse_condition_maybe_unordered (CODE))
+ @end smallexample
+ 
  @end table
  
  @node Costs

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