public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <law@redhat.com>
To: Richard Biener <rguenther@suse.de>
Cc: Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>,
	       gcc Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [tree-tailcall] Check if function returns it's argument
Date: Mon, 05 Dec 2016 22:53:00 -0000	[thread overview]
Message-ID: <f1455c7a-7804-59c7-aee4-54bd4b12325b@redhat.com> (raw)
In-Reply-To: <alpine.LSU.2.11.1612020931490.5294@t29.fhfr.qr>

On 12/02/2016 01:33 AM, Richard Biener wrote:
>> The LHS on the assignment makes it easier to identify when a tail call is
>> possible.  It's not needed for correctness.  Not having the LHS on the
>> assignment just means we won't get an optimized tail call.
>>
>> Under what circumstances would the LHS possibly be removed?  We know the
>> return statement references the LHS, so it's not going to be something that
>> DCE will do.
>
> Well, I thought Prathamesh added the optimization to copy-propagate
> the lhs from the returned argument.  So we'd have both transforms here.
That seems like a mistake -- the fact that we can copy propagate the LHS 
from the returned argument is interesting, but in practice I've found it 
to not be useful to do so.

The problem is it makes the value look live across a the call and we're 
then dependent upon the register allocator to know the trick about the 
returned argument value and apply it consistently -- which it does not 
last I checked.

I think we're better off leaving the call in the form of LHS = call () 
if the return value is used.  That's going to be more palatable to tail 
calling.

>
> Of course as always the user could have written the code in this way.
>
> If the LHS is not required for correctness then I don't think we need
> to put it there - Pratamesh verified the call is tail-called already
> if marked by the tailcall pass, even if the LHS is not present.
But if the function returns the value from the tail call, then going 
through an LHS is the right thing to do.  Using the magic "argX will be 
the return value" seems clever, but actually hurts in practice.
jeff

  reply	other threads:[~2016-12-05 22:53 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-24  7:18 Prathamesh Kulkarni
2016-11-24  8:37 ` Richard Biener
2016-11-24 12:15   ` Prathamesh Kulkarni
2016-11-24 12:18     ` Richard Biener
2016-11-24 12:21       ` Jakub Jelinek
2016-11-24 12:23         ` Richard Biener
2016-11-24 12:32       ` Prathamesh Kulkarni
2016-11-24 12:38         ` Richard Biener
2016-11-25  5:16           ` Prathamesh Kulkarni
2016-11-25  8:07             ` Richard Biener
2016-11-25  8:18               ` Prathamesh Kulkarni
2016-11-25  8:25                 ` Richard Biener
2016-11-25  8:31                   ` Prathamesh Kulkarni
2016-11-25 15:47               ` Jeff Law
2016-12-01 11:42                 ` Prathamesh Kulkarni
2016-12-01 12:10                   ` Richard Biener
2016-12-01 12:50                     ` Prathamesh Kulkarni
2016-12-01 12:56                       ` Richard Biener
2016-12-01 13:05                         ` Prathamesh Kulkarni
2016-12-01 13:08                           ` Richard Biener
2016-12-01 13:18                             ` Prathamesh Kulkarni
2016-12-01 13:22                               ` Richard Biener
2016-12-01 22:27                                 ` Jeff Law
2016-12-02  6:04                                   ` Prathamesh Kulkarni
2016-12-02  8:33                                   ` Richard Biener
2016-12-05 22:53                                     ` Jeff Law [this message]
2016-12-06  8:25                                       ` Richard Biener
2016-12-06 10:16                                         ` Richard Biener
2016-12-07 21:20                                           ` Jeff Law
2016-12-09  8:10                                             ` Richard Biener
2016-12-12 16:36                                               ` Jeff Law
2016-12-07 16:54                                         ` Jeff Law

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=f1455c7a-7804-59c7-aee4-54bd4b12325b@redhat.com \
    --to=law@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=prathamesh.kulkarni@linaro.org \
    --cc=rguenther@suse.de \
    /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).