Skip to content

Commit 222ec9d

Browse files
committed
[ValueTracking] Add missing check for two-value PN recurrance matching
When InstTy is a type like IntrinsicInst which can have a variable number of arguments, we can encounter a case where Opetaion will have fewer than two arguments and error at the getOperand() calls.
1 parent 82d633e commit 222ec9d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9147,7 +9147,8 @@ static bool matchTwoInputRecurrence(const PHINode *PN, InstTy *&Inst,
91479147
return false;
91489148

91499149
for (unsigned I = 0; I != 2; ++I) {
9150-
if (auto *Operation = dyn_cast<InstTy>(PN->getIncomingValue(I))) {
9150+
if (auto *Operation = dyn_cast<InstTy>(PN->getIncomingValue(I));
9151+
Operation && Operation->getNumOperands() == 2) {
91519152
Value *LHS = Operation->getOperand(0);
91529153
Value *RHS = Operation->getOperand(1);
91539154
if (LHS != PN && RHS != PN)

0 commit comments

Comments
 (0)