linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dibyendu Majumdar <mobile@majumdar.org.uk>
To: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Cc: Linux-Sparse <linux-sparse@vger.kernel.org>
Subject: Re: Sparse-llvm question regarding handling of phi/phsrc instructions
Date: Fri, 8 Sep 2017 11:11:08 +0100	[thread overview]
Message-ID: <CACXZuxebbu2h4iSXduwaBVxLaubj_ZSnp_c8_tZncRfK5DbpWA@mail.gmail.com> (raw)
In-Reply-To: <CACXZuxexgWjzvvZC-YNbzfaGuLyB+ovkJcdAkkySN8FF13XsrA@mail.gmail.com>

Hi Luc,

On 7 September 2017 at 21:33, Dibyendu Majumdar <mobile@majumdar.org.uk> wrote:
> On 7 September 2017 at 21:25, Luc Van Oostenryck
> <luc.vanoostenryck@gmail.com> wrote:
>> 2017-09-07 18:04 GMT+02:00 Dibyendu Majumdar <mobile@majumdar.org.uk>:
>>> The following code snippet:
>>>
>>> static int test_do(void) {
>>>     int a = 0;
>>>     int count = 27;
>>>     switch (count % 8) {
>>>     case 0: do {  a++;
>>>     case 7:       a++;
>>>     case 6:       a++;
>>>     case 5:       a++;
>>>     case 4:       a++;
>>>     case 3:       a++;
>>>     case 2:       a++;
>>>     case 1:       a++;
>>>             } while ((count -= 8) > 0);
>>>     }
>>>     return a;
>>> }
>>>
>>> Results in following linear output:
>>>
>>> test_do:
>>> .L0:
>>>         <entry-point>
>>>         phisrc.32   %phi3(a) <- $0
>>>         phisrc.32   %phi4(a) <- $0
>>>         phisrc.32   %phi6(a) <- $0
>>>         phisrc.32   %phi8(a) <- $0
>>>         phisrc.32   %phi10(a) <- $0
>>>         phisrc.32   %phi12(a) <- $0
>>>         phisrc.32   %phi14(a) <- $0
>>>         phisrc.32   %phi16(a) <- $0
>>>         phisrc.32   %phi18(a) <- $0
>>>         phisrc.32   %phi20(count) <- $27
>>>         br          .L7
>>>
>>> .L10:
>>>         phi.32      %r3 <- %phi18(a), %phi19(a)
>>>         add.32      %r4 <- %r3, $1
>>>         phisrc.32   %phi17(a) <- %r4
>>>         phi.32      %r5 <- %phi16(a), %phi17(a)
>>> ...
>>>
>>> It seems to me that 'a' ends up having 9 different slots on the stack,
>>> but it should really be merged into one slot, i.e. we should detect
>>> that the phis all related to the same symbol, and create only one
>>> alloca?
>>
>>

What is also interesting is that in the old way by switching off the
simplifications the generated code avoids all the phis and is actually
simpler in terms of memory operations in the backend. Now LLVM can
sort this out easily as it transforms this to use phis anyway, but my
other backend is simpler, and for that non SSA version is better.

Regards
Dibyendu

      reply	other threads:[~2017-09-08 10:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-07 16:04 Sparse-llvm question regarding handling of phi/phsrc instructions Dibyendu Majumdar
2017-09-07 20:25 ` Luc Van Oostenryck
2017-09-07 20:33   ` Dibyendu Majumdar
2017-09-08 10:11     ` Dibyendu Majumdar [this message]

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=CACXZuxebbu2h4iSXduwaBVxLaubj_ZSnp_c8_tZncRfK5DbpWA@mail.gmail.com \
    --to=mobile@majumdar.org.uk \
    --cc=linux-sparse@vger.kernel.org \
    --cc=luc.vanoostenryck@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 NNTP newsgroup(s).