Skip to content

Commit e9a9371

Browse files
committed
test
1 parent 3de59f7 commit e9a9371

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

llvm/lib/Transforms/InstCombine/InstructionCombining.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,14 +1738,17 @@ Instruction *InstCombinerImpl::FoldOpIntoSelect(Instruction &Op, SelectInst *SI,
17381738
if (SI->getType()->isIntOrIntVectorTy(1))
17391739
return nullptr;
17401740

1741-
// Avoid breaking min/max reduction pattern,
1741+
// Avoid breaking reduction pattern,
17421742
// which is necessary for vectorization later.
1743-
if (isa<MinMaxIntrinsic>(&Op))
1744-
for (Value *IntrinOp : Op.operands())
1745-
if (auto *PN = dyn_cast<PHINode>(IntrinOp))
1746-
for (Value *PhiOp : PN->operands())
1747-
if (PhiOp == &Op)
1748-
return nullptr;
1743+
PHINode *PhiNode;
1744+
Value *Start, *Step;
1745+
if (auto *BinOp = dyn_cast<BinaryOperator>(&Op)) {
1746+
if (matchSimpleRecurrence(BinOp, PhiNode, Start, Step))
1747+
return nullptr;
1748+
} else if (auto *II = dyn_cast<IntrinsicInst>(&Op)) {
1749+
if (matchSimpleBinaryIntrinsicRecurrence(II, PhiNode, Start, Step))
1750+
return nullptr;
1751+
}
17491752

17501753
// Test if a FCmpInst instruction is used exclusively by a select as
17511754
// part of a minimum or maximum operation. If so, refrain from doing

0 commit comments

Comments
 (0)