Skip to content

Commit 1e9166c

Browse files
Address reviewer's comments and simplify the code.
1 parent fbc4a5f commit 1e9166c

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,8 +1668,8 @@ Instruction *InstCombinerImpl::visitPHINode(PHINode &PN) {
16681668
DiffValBB = PredBB;
16691669
}
16701670
}
1671-
BasicBlock *CurBB = PN.getParent();
1672-
if (DiffVals == 2 || DiffValBB != CurBB)
1671+
// The case that DiffVals == 0 is already handled.
1672+
if (DiffVals == 2)
16731673
continue;
16741674
// Now check that the backedge incoming values are two select
16751675
// instructions that are in the same BB, and have the same condition.
@@ -1682,9 +1682,6 @@ Instruction *InstCombinerImpl::visitPHINode(PHINode &PN) {
16821682

16831683
auto *SI = cast<SelectInst>(Val);
16841684
auto *IdenticalSI = cast<SelectInst>(IdenticalVal);
1685-
if (SI->getParent() != CurBB || IdenticalSI->getParent() != CurBB ||
1686-
SI->getNumUses() != 1)
1687-
continue;
16881685
if (SI->getCondition() != IdenticalSI->getCondition() ||
16891686
(SI->getTrueValue() != IdenticalSI->getTrueValue() &&
16901687
SI->getFalseValue() != IdenticalSI->getFalseValue()))
@@ -1713,8 +1710,7 @@ Instruction *InstCombinerImpl::visitPHINode(PHINode &PN) {
17131710
if (cast<PHINode>(IdenticalSIOtherVal) != &IdenticalPN)
17141711
continue;
17151712
auto *SIOtherValAsSel = cast<SelectInst>(SIOtherVal);
1716-
if (SIOtherValAsSel->getParent() != CurBB ||
1717-
!SameSelAndPhi(SIOtherValAsSel, &IdenticalPN, &PN))
1713+
if (!SameSelAndPhi(SIOtherValAsSel, &IdenticalPN, &PN))
17181714
continue;
17191715

17201716
++NumPHICSEs;

0 commit comments

Comments
 (0)