This is the mail archive of the 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] tree-ssa-ccp.c: Fold references into constant aggregates.

On Sat, May 07, 2005 at 05:34:17PM -0400, Kazu Hirata wrote:
>   Richard Henderson said that the TREE_SIDE_EFFECTS check in Steven's
>   original patch was useless, but expr.c:6945 checks
>   TREE_SIDE_EFFECTS.  Could that be a problem?

I might guess that the expr.c check is there for cases that can't
happen anymore.  You could assert no side effects if you like.  Or
I guess just leave it alone for now.

>   1. replace X and Y with constants.
>   2. pass the expression to fold or fold_stmt
>   3. if folding is unsuccessful, put X and Y back.
>   I felt this was a bit tedious.  I guess one could use


> +      if (compare_tree_int (idx, list_length (CONSTRUCTOR_ELTS (ctor))) < 0)
> +	{
> +	  /* Whoo-hoo!  I'll fold ya baby.  Yeah!  */
> +	  HOST_WIDE_INT i;
> +
> +	  for (elt = CONSTRUCTOR_ELTS (ctor), i = TREE_INT_CST_LOW (idx);
> +	       elt != 0 && i != 0;
> +	       i--, elt = TREE_CHAIN (elt))
> +	    /* Find that element.  */
> +	    ;

You're traversing the list twice here.  Plus I believe you'll have to 
deal with RANGE_EXPRs from the C++ front end.  So there is not in fact
a 1-1 mapping for indicies.

Otherwise it looks ok.


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