[llvm] 32ec5fb - [ValueTracking] Use BinaryOperator instead of Operator in matchSimpleRecurrence. (#74678)

via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 7 10:28:01 PST 2023


Author: Craig Topper
Date: 2023-12-07T10:27:57-08:00
New Revision: 32ec5fbfed32f37aa070ee38e9b038bd84ca6479

URL: https://github.com/llvm/llvm-project/commit/32ec5fbfed32f37aa070ee38e9b038bd84ca6479
DIFF: https://github.com/llvm/llvm-project/commit/32ec5fbfed32f37aa070ee38e9b038bd84ca6479.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/lib/Analysis/ValueTracking.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 2c52107dab23b..dfd36862b05c1 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -8024,7 +8024,7 @@ bool llvm::matchSimpleRecurrence(const PHINode *P, BinaryOperator *&BO,
   for (unsigned i = 0; i != 2; ++i) {
     Value *L = P->getIncomingValue(i);
     Value *R = P->getIncomingValue(!i);
-    Operator *LU = dyn_cast<Operator>(L);
+    auto *LU = dyn_cast<BinaryOperator>(L);
     if (!LU)
       continue;
     unsigned Opcode = LU->getOpcode();
@@ -8062,7 +8062,7 @@ bool llvm::matchSimpleRecurrence(const PHINode *P, BinaryOperator *&BO,
     // OR
     //   %iv = [R, %entry], [%iv.next, %backedge]
     //   %iv.next = binop L, %iv
-    BO = cast<BinaryOperator>(LU);
+    BO = LU;
     Start = R;
     Step = L;
     return true;


        


More information about the llvm-commits mailing list