[tuples] Tuplify some passes
Zdenek Dvorak
rakdver@kam.mff.cuni.cz
Wed Jun 11 21:18:00 GMT 2008
Hi,
> >> > the simplest solution seems to be to make get_val_for return &buf + 2 in this
> >> > case.
> >>
> >> Yes, but it'd have to be an old-style tree, not a tuple. I'm not sure
> >> if we want that. Do we build this kind of trees elsewhere on the
> >> tuples branch?
> >
> > yes -- certainly in scev analysis and all the related analyses,
>
> OK, so you mean something like the following patch?
more or less:
> - FOR_EACH_SSA_USE_OPERAND (op, stmt, iter, SSA_OP_USE)
> - {
> - /* FIXME -- rewriting the statement this way in order to fold its rhs
> - is an ugly hack. */
> - nx = USE_FROM_PTR (op);
> - val = get_val_for (nx, base);
> - SET_USE (op, val);
> - val = gimple_fold (stmt);
> - SET_USE (op, nx);
> - /* only iterate loop once. */
> - return val;
> + op1 = gimple_assign_rhs1 (stmt);
> + op2 = gimple_assign_rhs2 (stmt);
Changing the code this way will require also changing
chain_of_csts_start to check that
gimple_assign_rhs1 (stmt) or gimple_assign_rhs2 (stmt) is an ssa name
(just now statements like
... = &a[ssa_name]
are allowed, which would not be handled correctly by the changed code)
> + code = gimple_assign_rhs_code (stmt);
> + if (TREE_CODE (op1) != SSA_NAME)
> + {
> + gcc_assert (TREE_CODE (op2) == SSA_NAME);
> + tmp = op1;
> + op1 = op2;
> + op2 = tmp;
> }
This should be
if (TREE_CODE (op1) == SSA_NAME)
op1 = get_val_for (op1, base)
else
op2 = get_val_for (op2, base)
return fold_build2 (code, TREE_TYPE (x), op1, op2);
(code does not have to be commutative)
Zdenek
>
> - /* Should never reach here. */
> - gcc_unreachable ();
> + val = get_val_for (op1, base);
> + return fold_build2 (code, TREE_TYPE (op1), val, op2);
> }
>
> /* Tries to count the number of iterations of LOOP till it exits by EXIT
More information about the Gcc-patches
mailing list