Skip to content

Commit 32ec5fb

Browse files
authored
[ValueTracking] Use BinaryOperator instead of Operator in matchSimpleRecurrence. (#74678)
Operator allows the phi operand to be a ConstantExpr. A ConstantExpr is a valid operand to a phi, but is never going to be a recurrence. We can only match a BinaryOperator so use that instead.
1 parent ea991a1 commit 32ec5fb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8024,7 +8024,7 @@ bool llvm::matchSimpleRecurrence(const PHINode *P, BinaryOperator *&BO,
80248024
for (unsigned i = 0; i != 2; ++i) {
80258025
Value *L = P->getIncomingValue(i);
80268026
Value *R = P->getIncomingValue(!i);
8027-
Operator *LU = dyn_cast<Operator>(L);
8027+
auto *LU = dyn_cast<BinaryOperator>(L);
80288028
if (!LU)
80298029
continue;
80308030
unsigned Opcode = LU->getOpcode();
@@ -8062,7 +8062,7 @@ bool llvm::matchSimpleRecurrence(const PHINode *P, BinaryOperator *&BO,
80628062
// OR
80638063
// %iv = [R, %entry], [%iv.next, %backedge]
80648064
// %iv.next = binop L, %iv
8065-
BO = cast<BinaryOperator>(LU);
8065+
BO = LU;
80668066
Start = R;
80678067
Step = L;
80688068
return true;

0 commit comments

Comments
 (0)