This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] tree-ssa-ccp.c: Fold references into constant aggregates.
- From: Richard Henderson <rth at redhat dot com>
- To: Kazu Hirata <kazu at cs dot umass dot edu>
- Cc: gcc-patches at gcc dot gnu dot org, dnovillo at redhat dot com, stevenb at suse dot de
- Date: Sat, 7 May 2005 15:51:37 -0700
- Subject: Re: [patch] tree-ssa-ccp.c: Fold references into constant aggregates.
- References: <20050507.173417.100075707.kazu@cs.umass.edu>
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
> FOR_EACH_SSA_USE_OPERAND and SET_USE.
Ok.
> + 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.
r~