[PATCH] D35474: SSAUpdater: Add mode when Phi creation is not allowed

Serguei Katkov via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 31 20:01:21 PDT 2017


Hi Daniel,

please take a look into https://reviews.llvm.org/D36073

It contains a couple of tests which shows the patterns I'm trying to resolve.
In reality the pattern might be more complex.

shortly for the case
BB1:
p1 = b1 + 40
p2 = b2 + 40
br cond, BB2, BB3
BB2:
br BB3
BB3:
p = phi [p1, BB2], [p2, BB3]
v = load p

I want to see in BB3:
b = phi [b1, BB2], [b2, BB3]
p.b = b + 40
v = load p.b
(after that p, p1, p2 will be eliminated)

Please note that in the original test
p = phi [p1, BB3], [p2, BB2]

then I need
b = phi [b1, BB3], [b2, BB2]


Thank you,
Serguei.

From: Daniel Berlin [mailto:dberlin at dberlin.org]
Sent: Tuesday, August 1, 2017 12:39 AM
To: reviews+D35474+public+a0659378412bff14 at reviews.llvm.org
Cc: Serguei Katkov <serguei.katkov at azul.com>; Pete Cooper <peter_cooper at apple.com>; sabre+phabricator at nondot.org; Bob Wilson <bob.wilson at apple.com>; Friedman, Eli <efriedma at codeaurora.org>; llvm-commits <llvm-commits at lists.llvm.org>
Subject: Re: [PATCH] D35474: SSAUpdater: Add mode when Phi creation is not allowed



On Mon, Jul 31, 2017 at 12:21 AM, Serguei Katkov via Phabricator <reviews at reviews.llvm.org<mailto:reviews at reviews.llvm.org>> wrote:
skatkov abandoned this revision.
skatkov added a comment.

Hi Daniel,

I've come up with the following implementation basing on your idea: https://reviews.llvm.org/D36073

Please take into account that finally I realized that I could not use SSAUpdater API because it is possible that I can observe the base instruction in the same BB but the difference might be in the path I can get it.
Simple example:
p1 = b1 + 40
p2 = b2 + 40
p = p1
if (cond) p = p2
v = *(p)

So I have p1 and p2 in the same basic block, so I cannot say to SSA update that I saw b1 and b2 in the same basic block to get the right phi node merging b1 and b2.

(I assume this if is turning into a select)
Right, you have to write/read the definitions in the right order, even with the new API.

It's possible toavoid this issue by adding local dominance info using ordered instructions, and then you could just add them in any order.

I'm pretty sure we could design something that worked a little better for you.

Do you have an example of what you want the above output fo actually produce in terms of phi nodes?
I hope the right implementation may b found in https://reviews.llvm.org/D36073


https://reviews.llvm.org/D35474



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170801/ade74bcd/attachment.html>


More information about the llvm-commits mailing list