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]

Re: [tree-ssa ] Misc small improvements


On Mon, 30 Jun 2003 20:06:23 -0600, law@redhat.com wrote:

> The expr.c change improves the code we generate for COND_EXPRs with one
> interesting arm that is a GOTO_EXPR.  This happens a lot just about
> everywhere.

Yep.  Here's my version of that patch, which I set aside because it didn't
deal with a saved stack position.  It handles more cases than yours, though
yours has better checks for cleanups and nonlocal goto.  Want to merge them
and look into the saved stack issue?

*** expr.c.~2~	2003-05-29 18:53:47.000000000 -0400
--- expr.c	2003-05-29 18:54:58.000000000 -0400
*************** expand_expr (exp, target, tmode, modifie
*** 8812,8818 ****
  	  tree then_ = TREE_OPERAND (exp, 1);
  	  tree else_ = TREE_OPERAND (exp, 2);
  
! 	  /* Just use the 'if' machinery.  */
  	  expand_start_cond (pred, 0);
  	  start_cleanup_deferral ();
  	  expand_expr (then_, const0_rtx, VOIDmode, 0);
--- 8812,8854 ----
  	  tree then_ = TREE_OPERAND (exp, 1);
  	  tree else_ = TREE_OPERAND (exp, 2);
  
! 	  /* If we've got a goto in an arm, make it a conditional jump.
! 
! 	     Note that this optimization breaks anything that actually
! 	     needs to go through expand_goto: nonlocal goto and goto in the
! 	     presence of cleanups or a saved stack position.
! 
! 	     FIXME test for saved stack position.  */
! 	  if (target_temp_slot_level)
! 	    /* There are cleanups.  */;
! 	  else if (TREE_CODE (then_) == GOTO_EXPR
! 		   && TREE_CODE (GOTO_DESTINATION (then_)) == LABEL_DECL
! 		   && DECL_ARTIFICIAL (GOTO_DESTINATION (then_)))
! 	    {
! 	      rtx true_label = label_rtx (GOTO_DESTINATION (then_));
! 	      if (TREE_CODE (else_) == GOTO_EXPR
! 		  && TREE_CODE (GOTO_DESTINATION (else_)) == LABEL_DECL
! 		  && DECL_ARTIFICIAL (GOTO_DESTINATION (else_)))
! 		{
! 		  rtx false_label = label_rtx (GOTO_DESTINATION (else_));
! 		  do_jump (pred, false_label, true_label);
! 		  return const0_rtx;
! 		}
! 	      else
! 		{
! 		  jumpif (pred, true_label);
! 		  return expand_expr (else_, const0_rtx, VOIDmode, 0);
! 		}
! 	    }
! 	  else if (TREE_CODE (else_) == GOTO_EXPR
! 		   && TREE_CODE (GOTO_DESTINATION (else_)) == LABEL_DECL
! 		   && DECL_ARTIFICIAL (GOTO_DESTINATION (else_)))
! 	    {
! 	      jumpifnot (pred, label_rtx (GOTO_DESTINATION (else_)));
! 	      return expand_expr (then_, const0_rtx, VOIDmode, 0);
! 	    }
! 
! 	  /* Otherwise, use the 'if' machinery.  */
  	  expand_start_cond (pred, 0);
  	  start_cleanup_deferral ();
  	  expand_expr (then_, const0_rtx, VOIDmode, 0);

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