[PATCH] PR middle-end/14531: Call fold in g++'s build_base_path

Roger Sayle roger@eyesopen.com
Tue Apr 20 03:07:00 GMT 2004


On Mon, 19 Apr 2004, Jason Merrill wrote:
> On Mon, 19 Apr 2004 10:39:59 -0600 (MDT), Roger Sayle <roger@eyesopen.com> wrote:
>
> >     if (null_test)
> > !     expr = fold (build3 (COND_EXPR, target_type, null_test, expr,
> > ! 			 fold (build1 (NOP_EXPR, target_type,
> > ! 				       integer_zero_node))));
>
> Are both folds necessary?  Perhaps fold for COND_EXPR should automatically
> fold the predicate argument.

Unfortunately, yes they're both necessary.  "fold" avoids the exponential
behaviour of a recursive function, by assuming that all the operands of
the current tree node have already been folded.  The burden is then on
the front or middle-end to fold trees as they're built.

I'm about to commit a patch that should avoid directly calling "build1"
and "fold" in the quoted example above, by exporting the function
fold_convert outside of fold-const.c, so that it can be used elsewhere.


> Up to you; this patch is OK.

Many thanks.  Committed.

Roger
--



More information about the Gcc-patches mailing list