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] fold-const.c use of BRANCH_COST


	While investigating PowerPC performance, I have discovered that
the threshold levels used to test BRANCH_COST are not always correct for
PowerPC.  Instead of arguing to change the threshold, I propose allowing
the test to be overridden in the machine description, with the default
being the former BRANCH_COST-based test.

	If the patch below is approved, I will add the appropriate
documentation as well.  The motivation is:

Unmodified:
   200.sixtrack      1100       651       169*     1100       535      206*
   254.gap           1100       249       442*     1100       262      419*
   255.vortex        1900       283       672*     1900       275      691*

BRANCH_COST=1:
   200.sixtrack      1100      1492      73.7*     1100       743      148*
   254.gap           1100       248       444*     1100       239      460*
   255.vortex        1900       293       647*     1900       276      688*

Modified fold-const.c only:
   200.sixtrack      1100       649       169*     1100       675      163*
   254.gap           1100       281       391*     1100       249      442*
   255.vortex        1900       295       644*     1900       275      692*

Modified fold-const.c:fold_range_test() only:
   200.sixtrack      1100       964       114*     1100       529      208*
   254.gap           1100       245       449*     1100       243      452*
   255.vortex        1900       284       668*     1900       274      694*

Yes, BRANCH_COST=1 really does degrade 200.sixtrack that much -- it is
completely repeatable.

Thanks, David


	* fold-const.c (fold_range_test): Add new macro defaulting
	to BRANCH_COST.

Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.242
diff -c -p -r1.242 fold-const.c
*** fold-const.c	23 Mar 2003 22:57:25 -0000	1.242
--- fold-const.c	9 Apr 2003 19:25:26 -0000
*************** fold_range_test (exp)
*** 3449,3455 ****
    /* On machines where the branch cost is expensive, if this is a
       short-circuited branch and the underlying object on both sides
       is the same, make a non-short-circuit operation.  */
!   else if (BRANCH_COST >= 2
  	   && lhs != 0 && rhs != 0
  	   && (TREE_CODE (exp) == TRUTH_ANDIF_EXPR
  	       || TREE_CODE (exp) == TRUTH_ORIF_EXPR)
--- 3449,3460 ----
    /* On machines where the branch cost is expensive, if this is a
       short-circuited branch and the underlying object on both sides
       is the same, make a non-short-circuit operation.  */
! 
! #ifndef RANGE_TEST_SHORT_CIRCUIT
! #define RANGE_TEST_SHORT_CIRCUIT (BRANCH_COST >= 2)
! #endif
! 
!   else if (RANGE_TEST_SHORT_CIRCUIT
  	   && lhs != 0 && rhs != 0
  	   && (TREE_CODE (exp) == TRUTH_ANDIF_EXPR
  	       || TREE_CODE (exp) == TRUTH_ORIF_EXPR)


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