[PATCH] D24805: [GVNSink] Initial GVNSink prototype

Daniel Berlin via llvm-commits llvm-commits at lists.llvm.org
Thu May 25 08:11:43 PDT 2017


(That comment applies mostly to newgvn).

In your case, i believe the code is just wrong:

/ This assumes the PHI is already well-formed and there aren't conflicting
    // incoming values for the same block.
    for (auto *B : Blocks)
      Values.push_back(PN->getIncomingValueForBlock(B))

It's 100% completely and definitely possible for a phi to have two values
incoming from the same block, actually, regardless of whether it's a self
block or not.
This happens using switch statements.
I believe we even have some testcases in newgvn for multiple edges from
same incoming block.

So yeah, you have to handle them here.


On Thu, May 25, 2017 at 8:08 AM, Daniel Berlin <dberlin at dberlin.org> wrote:

>
>> ----------------
>> dberlin wrote:
>> > I'm curious why you think you need stable sort here as opposed to
>> regular
>> >
>> I don't. Changed.
>>
>>
> (i'm offsite today, but someone should test this in newgvn too if i'm
> right).
>
> Do we allow switch statements with multiple edges to ourself?
>
> ie
>
> bb1:
>
> switch <whatever> [
> i32 0 : label bb1
> i32 1: label bb1 ]
>
>
> (which, after propagation,  could cause a phi with different operands and
> the same incoming blocks)
> If so, either we need stable sorts, or a better ordering of incoming
> blocks, because the pointer equality we use will not definitely sort them
> into a consistent order
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170525/fd365720/attachment.html>


More information about the llvm-commits mailing list