mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-26 13:36:28 +00:00
The select instruction is not neccesarily in the same block as the
phi nodes. Make sure to phi translate from the right block. This fixes a llvm-building-llvm failure on GVN-PRE.cpp llvm-svn: 82970
This commit is contained in:
parent
ddc8678b00
commit
d77fb17b28
@ -2002,10 +2002,11 @@ Instruction *InstCombiner::FoldOpIntoPhi(Instruction &I,
|
||||
// not the true/false values.
|
||||
Value *TrueV = SI->getTrueValue();
|
||||
Value *FalseV = SI->getFalseValue();
|
||||
BasicBlock *PhiTransBB = PN->getParent();
|
||||
for (unsigned i = 0; i != NumPHIValues; ++i) {
|
||||
BasicBlock *ThisBB = PN->getIncomingBlock(i);
|
||||
Value *TrueVInPred = TrueV->DoPHITranslation(I.getParent(), ThisBB);
|
||||
Value *FalseVInPred = FalseV->DoPHITranslation(I.getParent(), ThisBB);
|
||||
Value *TrueVInPred = TrueV->DoPHITranslation(PhiTransBB, ThisBB);
|
||||
Value *FalseVInPred = FalseV->DoPHITranslation(PhiTransBB, ThisBB);
|
||||
Value *InV = 0;
|
||||
if (Constant *InC = dyn_cast<Constant>(PN->getIncomingValue(i))) {
|
||||
InV = InC->isNullValue() ? FalseVInPred : TrueVInPred;
|
||||
|
@ -247,3 +247,19 @@ ret:
|
||||
%b = select i1 %a, i32 %A, i32 %c
|
||||
ret i32 %b
|
||||
}
|
||||
|
||||
define i32 @test29(i1 %cond, i32 %A, i32 %B) {
|
||||
entry:
|
||||
br i1 %cond, label %jump, label %ret
|
||||
jump:
|
||||
br label %ret
|
||||
ret:
|
||||
%c = phi i32 [%A, %jump], [%B, %entry]
|
||||
%a = phi i1 [true, %jump], [false, %entry]
|
||||
br label %next
|
||||
|
||||
next:
|
||||
%b = select i1 %a, i32 %A, i32 %c
|
||||
ret i32 %b
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user