This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [tree-ssa][RFC] An interface to fold(tree)
- From: Roger Sayle <roger at eyesopen dot com>
- To: Jeff Law <jeff at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 17 Oct 2003 20:36:38 -0600 (MDT)
- Subject: Re: [tree-ssa][RFC] An interface to fold(tree)
Jeff Law wrote:
> I'd rather have an interface like
>
> fold_tree (code, type, arg0, arg1, arg2, arg3)
> {
> most of the code currently in fold ()
> }
>
> [ Or however many arguments the largest tree code has :-0 ]
>
>
> fold then becomes
>
> fold (tree exp)
> {
> code = TREE_CODE (exp);
> type = TREE_TYPE (exp);
>
> for (i = 0; i < noperands; i++)
> op[i] = TREE_OPERAND (exp, i);
>
> return fold_tree (code, type, op[0], op[1], op[2], op[3]);
> }
>
> Thoughts?
Just to agree with Jeff, I much prefer this approach.
Instead of having a single fold_tree with an arbitrary number of
arguments, some of which may be NULL_TREE, I'd suggest pushing
the role model of "simplify_rtx" even further, and have several
"baby-folds": fold_unary, fold_binary, fold_ternary, etc...
Not unlike Jeff's non_destructive_fold_unary, etc.. on tree-ssa.
I also like the simplify_rtx model of returning NULL_TREE if no
simplification can be made. The last line of the pseudo-code
above then becomes:
temp = fold_tree (code, type, op[0], op[1], op[2], op[3]);
return temp ? temp : exp;
and we save generating a few more temporary trees.
Roger
--