From: "H.J. Lu" <hjl@lucon.org>
To: Richard Guenther <richard.guenther@gmail.com>
Cc: gcc-patches@gcc.gnu.org, ghazi@caip.rutgers.edu
Subject: Re: PATCH: PR middle-end/33007: builtin lround doesn't work
Date: Mon, 20 Aug 2007 18:46:00 -0000 [thread overview]
Message-ID: <20070820182502.GA11529@lucon.org> (raw)
In-Reply-To: <84fc9c000708200132p2dbd73c7xbbb4120dada4e800@mail.gmail.com>
On Mon, Aug 20, 2007 at 10:32:24AM +0200, Richard Guenther wrote:
> 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.
>
The testcase is
long
foo (int i)
{
float x;
x = i;
return __builtin_lroundf (x);
}
When fold_fixed_mathfn is called the first time, integer_valued_real_p
returns false since it doesn't enough info. When fold_fixed_mathfn is
called after expand_builtin_int_roundingfn_2, integer_valued_real_p
returns true, fold_fixed_mathfn can perform optimization. Will your
suggestion lead to missed optimization?
H.J.
next prev parent reply other threads:[~2007-08-20 18:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-07 18:02 H.J. Lu
2007-08-20 9:58 ` Richard Guenther
2007-08-20 18:46 ` H.J. Lu [this message]
2007-08-21 8:45 ` Richard Guenther
2007-08-21 13:32 ` H.J. Lu
2007-08-21 13:45 ` Richard Guenther
2007-08-21 18:54 ` H.J. Lu
2007-08-21 19:18 ` Richard Guenther
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070820182502.GA11529@lucon.org \
--to=hjl@lucon.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=ghazi@caip.rutgers.edu \
--cc=richard.guenther@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).