linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Jonathan Neuschäfer" <j.neuschaefer@gmx.net>
To: Pekka Enberg <penberg@kernel.org>
Cc: "Jonathan Neuschäfer" <j.neuschaefer@gmx.net>,
	"Jeff Garzik" <jgarzik@pobox.com>,
	linux-sparse@vger.kernel.org,
	"Christopher Li" <sparse@chrisli.org>,
	"Jeff Garzik" <jgarzik@redhat.com>,
	"Linus Torvalds" <torvalds@linux-foundation.org>
Subject: Re: [PATCH 1/2] sparse, llvm: group PHI nodes at the top of each BB
Date: Tue, 16 Oct 2012 22:14:26 +0200	[thread overview]
Message-ID: <20121016201426.GD2932@debian.debian> (raw)
In-Reply-To: <CAOJsxLEEBYMF4qcyBSpS7kaumzpQFm0McNexRtft3UJVwp==Xg@mail.gmail.com>

On Tue, Oct 16, 2012 at 08:59:27PM +0300, Pekka Enberg wrote:
> On Fri, Oct 12, 2012 at 9:25 PM, Pekka Enberg <penberg@kernel.org> wrote:
> > Sounds plausible but I'm still uneasy with the idea that LLVM backend
> > needs to reshuffle instructions like this.

Actually, the situation of Phi nodes in LLVM is actually slightly more
complex: They require "one pair (of value and BB) for each predecessor
basic block of the current block"[1]. This mean that we'll sometimes
need to insert phi nodes into BBs that don't directly use a value.
Consider the following piece of C code:

	extern int done(void);
	extern void foo(int);

	static void test(void) {
		int i;
		for (i = 0; ; i++) {
			if (done())
				break;
			foo(i);
		}
	}

Running it through test-linearize exhibits the problem:
[ I renamed the basic blocks to L0-L3 to increase readability. ]

	test:
	.L0:
		<entry-point>
		phisrc.32   %phi2(i) <- $0
		br          .L1

	.L1:
		call.32     %r1 <- done
		br          %r1, .L3, .L2

	.L2:
		phi.32      %r2(i) <- %phi2(i), %phi3(i)
		call        foo, %r2(i)
		add.32      %r4 <- %r2(i), $1
		phisrc.32   %phi3(i) <- %r4
		br          .L1

	.L3:
		ret

To comply with the "LLVM rules" we'd need to move the phi intruction up
into "L1".


regards,
Jonathan

  reply	other threads:[~2012-10-16 20:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-09 23:34 [PATCH 1/2] sparse, llvm: group PHI nodes at the top of each BB Jonathan Neuschäfer
2012-10-09 23:34 ` [PATCH 2/2] sparse, llvm: Fix type of loaded values Jonathan Neuschäfer
2012-10-10  0:13   ` Jeff Garzik
2012-10-10  6:34     ` Pekka Enberg
2012-10-10  0:12 ` [PATCH 1/2] sparse, llvm: group PHI nodes at the top of each BB Jeff Garzik
2012-10-10  6:31   ` Pekka Enberg
2012-10-10 16:33     ` Jonathan Neuschäfer
2012-10-12 18:25       ` Pekka Enberg
2012-10-16 17:59         ` Pekka Enberg
2012-10-16 20:14           ` Jonathan Neuschäfer [this message]
2012-10-16 20:53             ` Xi Wang
2012-10-17  6:48               ` Pekka Enberg
2012-10-17  6:53                 ` Xi Wang
2012-10-17 16:41                   ` Pekka Enberg
2012-10-17 17:44                     ` Jonathan Neuschäfer
2013-05-15 12:05               ` Pekka Enberg
2013-05-16  5:28                 ` Xi Wang

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=20121016201426.GD2932@debian.debian \
    --to=j.neuschaefer@gmx.net \
    --cc=jgarzik@pobox.com \
    --cc=jgarzik@redhat.com \
    --cc=linux-sparse@vger.kernel.org \
    --cc=penberg@kernel.org \
    --cc=sparse@chrisli.org \
    --cc=torvalds@linux-foundation.org \
    /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).