Hi,
I noticed that if you create a switch with multiple cases going to
the same destination, then if that destination contains phis you
need to add the incoming value an equivalent number of times. The
attached code seems wrong, but it compiles as correct, and removing
the duplicated incoming node causes an error. Is this expected?
Cheers,
Gary
--
http://gbenson.net/
-------------- next part --------------
define internal i32 @func419(i32* %foo_addr, i32* %bar_addr, i32 %baz) {
%method = load i32* %foo_addr
br label %not_zero
not_zero:
switch i32 %baz, label %no_exception9 [
i32 6, label %bci_56
i32 7, label %bci_56
]
no_exception9:
%bar = load i32* %bar_addr
br label %bci_56
bci_56:
%method1 = phi i32 [ %method, %not_zero ], [ %method, %not_zero ], [ %bar,
%no_exception9 ]
ret i32 %method1
}
On Aug 27, 2008, at 3:37 AM, Gary Benson wrote:> Hi, > > I noticed that if you create a switch with multiple cases going to > the same destination, then if that destination contains phis you > need to add the incoming value an equivalent number of times. The > attached code seems wrong, but it compiles as correct, and removing > the duplicated incoming node causes an error. Is this expected?Hi Gary, I agree that this is somewhat annoying, but it is required to maintain the invariant that a phi node in a block has the same number of entries as the block has predecessors. -Chris
Chris Lattner wrote:> On Aug 27, 2008, at 3:37 AM, Gary Benson wrote: > > I noticed that if you create a switch with multiple cases going to > > the same destination, then if that destination contains phis you > > need to add the incoming value an equivalent number of times. > > The attached code seems wrong, but it compiles as correct, and > > removing the duplicated incoming node causes an error. Is this > > expected? > > I agree that this is somewhat annoying, but it is required to > maintain the invariant that a phi node in a block has the same > number of entries as the block has predecessors.That's cool, it's not annoying, just not what I expected :) Cheers, Gary -- http://gbenson.net/