[llvm-commits] [PATCH] fix bug in InstCombiner::visitPHINode()
Frits van Bommel
fvbommel at gmail.com
Sat Apr 16 07:07:03 PDT 2011
On Sat, Apr 16, 2011 at 2:46 PM, Jay Foad <jay.foad at gmail.com> wrote:
> I found this bug in InstCombiner::visitPHINode() by code inspection. I
> have no idea what symptoms it might cause, and I don't have a test
> case, but it looks obviously wrong to me: InValNo is an incoming value
> number, but it is used as an operand number, which is not the same
It looks like the only symptom would be a missed optimization.
The incorrect code checks whether the later non-PHI incoming values
are all equal to either a basic block or a previous incoming PHI
node, depending on whether the incoming value number is odd or
The original value is also re-checked, and that check will only
succeed if it was the first incoming value
(getOperandNumForIncomingValue(0) == 0), so in all other cases it will
simply choose not to do anything.
The 'first incoming value' case was apparently the only case currently
tested, which was why this didn't show up in 'make check'
: Which won't happen because they're not valid incoming values.
: Which won't happen because they're treated differently by PHIsEqualValue().
> Tested with "make check". OK to apply?
I've constructed some tests for this which I'll check in afterwards.
More information about the llvm-commits