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] Fix cgraph related PR opt/13729


On Sun, 18 Jan 2004, Jan Hubicka wrote:
> I also included patch to remove releavant changes in fold-const so the
> combining does not happen early.
>
> I am not quite sure what approach is better, both has it's advantages and
> disadvantages.  I will run SPECs on combination of these patches on x86-64
> and alpha and send results.
>
> Sat Jun  1 20:10:19 CEST 2002  Jan Hubicka  <jh@suse.cz>
> 	* fold-const.c (RANGE_TEST_NON_SHORT_CIRCUIT): Kill.
> 	(fold_range_test): Kill branch combining.
> 	(fold_truthop): Kill branch combining.


Hi Jan,

Rather than simply delete these optimizations, have you considered
simply changing their conditions such that they only trigger for
"BRANCH_COST >= 3" or "BRANCH_COST >= 4"?  You've only recently
increased the default BRANCH_COST for x86 to two, so this could
simply be an issue with parameter fine tuning.

I'd much rather that we are more selective about whether an
optimization fires or not, rather than simply remove it completely
from the source code [unless of course, its clearly a looser].
There may be non IA-32 platforms that still benefit from these
transformations!  And we still don't have the benchmark results
for IA-32 yet.


> *** gcc.old/fold-const.c	Sat Sep 27 23:30:31 2003
> --- gcc/fold-const.c	Fri Oct 17 15:31:36 2003
> *************** merge_ranges (int *pin_p, tree *plow, tr
> *** 3450,3459 ****
>     return 1;
>   }
>
> - #ifndef RANGE_TEST_NON_SHORT_CIRCUIT
> - #define RANGE_TEST_NON_SHORT_CIRCUIT (BRANCH_COST >= 2)
> - #endif
> -
>   /* EXP is some logical combination of boolean tests.  See if we can
>      merge it into some range test.  Return the new tree if so.  */
>
> --- 3450,3455 ----
> *************** fold_range_test (tree exp)
> *** 3486,3526 ****
>   					 in_p, low, high))))
>       return or_op ? invert_truthvalue (tem) : tem;
>
> -   /* 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 (RANGE_TEST_NON_SHORT_CIRCUIT
> - 	   && lhs != 0 && rhs != 0
> - 	   && (TREE_CODE (exp) == TRUTH_ANDIF_EXPR
> - 	       || TREE_CODE (exp) == TRUTH_ORIF_EXPR)
> - 	   && operand_equal_p (lhs, rhs, 0))
> -     {
> -       /* If simple enough, just rewrite.  Otherwise, make a SAVE_EXPR
> - 	 unless we are at top level or LHS contains a PLACEHOLDER_EXPR, in
> - 	 which cases we can't do this.  */
> -       if (simple_operand_p (lhs))
> - 	return build (TREE_CODE (exp) == TRUTH_ANDIF_EXPR
> - 		      ? TRUTH_AND_EXPR : TRUTH_OR_EXPR,
> - 		      TREE_TYPE (exp), TREE_OPERAND (exp, 0),
> - 		      TREE_OPERAND (exp, 1));
> -
> -       else if ((*lang_hooks.decls.global_bindings_p) () == 0
> - 	       && ! CONTAINS_PLACEHOLDER_P (lhs))
> - 	{
> - 	  tree common = save_expr (lhs);
> -
> - 	  if (0 != (lhs = build_range_check (TREE_TYPE (exp), common,
> - 					     or_op ? ! in0_p : in0_p,
> - 					     low0, high0))
> - 	      && (0 != (rhs = build_range_check (TREE_TYPE (exp), common,
> - 						 or_op ? ! in1_p : in1_p,
> - 						 low1, high1))))
> - 	    return build (TREE_CODE (exp) == TRUTH_ANDIF_EXPR
> - 			  ? TRUTH_AND_EXPR : TRUTH_OR_EXPR,
> - 			  TREE_TYPE (exp), lhs, rhs);
> - 	}
> -     }
> -
>     return 0;
>   }
>
> --- 3482,3487 ----
> *************** fold_truthop (enum tree_code code, tree
> *** 3688,3727 ****
>   		      truth_type, ll_arg, lr_arg);
>       }
>
> -   /* If the RHS can be evaluated unconditionally and its operands are
> -      simple, it wins to evaluate the RHS unconditionally on machines
> -      with expensive branches.  In this case, this isn't a comparison
> -      that can be merged.  Avoid doing this if the RHS is a floating-point
> -      comparison since those can trap.  */
> -
> -   if (BRANCH_COST >= 2
> -       && ! FLOAT_TYPE_P (TREE_TYPE (rl_arg))
> -       && simple_operand_p (rl_arg)
> -       && simple_operand_p (rr_arg))
> -     {
> -       /* Convert (a != 0) || (b != 0) into (a | b) != 0.  */
> -       if (code == TRUTH_OR_EXPR
> - 	  && lcode == NE_EXPR && integer_zerop (lr_arg)
> - 	  && rcode == NE_EXPR && integer_zerop (rr_arg)
> - 	  && TREE_TYPE (ll_arg) == TREE_TYPE (rl_arg))
> - 	return build (NE_EXPR, truth_type,
> - 		      build (BIT_IOR_EXPR, TREE_TYPE (ll_arg),
> - 			     ll_arg, rl_arg),
> - 		      integer_zero_node);
> -
> -       /* Convert (a == 0) && (b == 0) into (a | b) == 0.  */
> -       if (code == TRUTH_AND_EXPR
> - 	  && lcode == EQ_EXPR && integer_zerop (lr_arg)
> - 	  && rcode == EQ_EXPR && integer_zerop (rr_arg)
> - 	  && TREE_TYPE (ll_arg) == TREE_TYPE (rl_arg))
> - 	return build (EQ_EXPR, truth_type,
> - 		      build (BIT_IOR_EXPR, TREE_TYPE (ll_arg),
> - 			     ll_arg, rl_arg),
> - 		      integer_zero_node);
> -
> -       return build (code, truth_type, lhs, rhs);
> -     }
> -
>     /* See if the comparisons can be merged.  Then get all the parameters for
>        each side.  */
>
> --- 3649,3654 ----
>
>

--
Roger Sayle,                         E-mail: roger@eyesopen.com
OpenEye Scientific Software,         WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-473-0833


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