This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH: PR middle-end/33007: builtin lround doesn't work
- From: "Richard Guenther" <richard dot guenther at gmail dot com>
- To: "H.J. Lu" <hjl at lucon dot org>
- Cc: gcc-patches at gcc dot gnu dot org, ghazi at caip dot rutgers dot edu
- Date: Mon, 20 Aug 2007 10:32:24 +0200
- Subject: Re: PATCH: PR middle-end/33007: builtin lround doesn't work
- References: <20070807180243.GA15223@lucon.org>
On 8/7/07, H.J. Lu <hjl@lucon.org> wrote:
> fold_fixed_mathfn may turn builtin lround into FIX_TRUNC_EXPR. But
> expand_builtin_int_roundingfn_2 isn't prepared to deal with it. This
> patch checks return from expand_expr and handle FIX_TRUNC_EXPR.
>
This is not the right way to fix this really. Instead this is the
common problem
that build_call_expr folds the built expression. Instead for
/* Wrap the computation of the argument in a SAVE_EXPR, as we may
need to expand the argument again. This way, we will not perform
side-effects more the once. */
narg = builtin_save_expr (arg);
if (narg != arg)
{
arg = narg;
exp = build_call_expr (fndecl, 1, arg);
}
we should re-build the call expression _without_ folding it. (Or
rather we can fix
the place that created the call without folding it - that is, fold
during TER). See
for example expand_builtin_cexpi or others which make sure not to re-fold the
call expression.
Richard.