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: [PATCH][PING] 2 tiny but unreviewed patches


Hi Paolo,

> I'd rather do something like
> 
>   if (CONSTANT_P (lhs) && CONSTANT_P (rhs) && !CONSTANT_P (tem))
>     {
>       gcc_assert (GET_MODE (tem) != VOIDmode);
>       gcc_assert (GET_CODE (lhs) == CONST || GET_CODE (rhs) == CONST);
>       tem = gen_rtx_CONST (GET_MODE (tem), tem);
>     }

Two minor flaws:
- CONSTANT_P (tem) segfaults if used on NULL_RTX which may be returned by
  simplify_binary_operation
- CONSTANT_P not only accepts CONST_INTs and CONSTs but also LABEL_REFs and
  SYMBOL_REFs what would trigger the second assertion.

What about the attached more conservative version?
I've enabled the simplification only for combinations of CONSTs and CONST_INTs
because as I already said I'm a bit concerned about creating too complicated
CONST RTXs especially when LABEL_REFs and SYMBOL_REFs are involved.

Bootstrapped on s390, s390x and i686.
No testsuite regressions on s390 and s390x - i686 still running.

OK for mainline, provided i686 doesn't show regressions?

Bye,

-Andreas-


2006-02-21  Andreas Krebbel  <krebbel1@de.ibm.com>

	* simplify-rtx.c (simplify_plus_minus): Simplify within CONST terms.


Index: gcc/simplify-rtx.c
===================================================================
*** gcc/simplify-rtx.c.orig	2006-02-16 14:47:37.000000000 +0100
--- gcc/simplify-rtx.c	2006-02-21 10:14:03.000000000 +0100
*************** simplify_plus_minus (enum rtx_code code,
*** 3288,3295 ****
  		else if (swap_commutative_operands_p (lhs, rhs))
  		  tem = lhs, lhs = rhs, rhs = tem;
  
! 		tem = simplify_binary_operation (ncode, mode, lhs, rhs);
  
  		/* Reject "simplifications" that just wrap the two
  		   arguments in a CONST.  Failure to do so can result
  		   in infinite recursion with simplify_binary_operation
--- 3288,3308 ----
  		else if (swap_commutative_operands_p (lhs, rhs))
  		  tem = lhs, lhs = rhs, rhs = tem;
  
! 		if ((GET_CODE (lhs) == CONST || GET_CODE (lhs) == CONST_INT)
! 		    && (GET_CODE (rhs) == CONST || GET_CODE (rhs) == CONST_INT))
! 		  {
! 		    rtx tem_lhs, tem_rhs;
! 
! 		    tem_lhs = GET_CODE (lhs) == CONST ? XEXP (lhs, 0) : lhs;
! 		    tem_rhs = GET_CODE (rhs) == CONST ? XEXP (rhs, 0) : rhs;
! 		    tem = simplify_binary_operation (ncode, mode, tem_lhs, tem_rhs);
  
+ 		    if (tem && !CONSTANT_P (tem))
+ 		      tem = gen_rtx_CONST (GET_MODE (tem), tem);
+ 		  }
+ 		else
+ 		  tem = simplify_binary_operation (ncode, mode, lhs, rhs);
+ 		
  		/* Reject "simplifications" that just wrap the two
  		   arguments in a CONST.  Failure to do so can result
  		   in infinite recursion with simplify_binary_operation


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