[llvm] [ValueTracking] Use Instruction instead of Operator in matchSimpleRecurrence. (PR #74678)

via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 6 15:48:11 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-analysis

Author: Craig Topper (topperc)

<details>
<summary>Changes</summary>

Operator allows the phi operand to be a ConstantExpr. A ConstantExpr is a valid operand to a phi, but a ConstantExpr is never going to be a recurrence. So I think we should use Instruction.

---
Full diff: https://github.com/llvm/llvm-project/pull/74678.diff


1 Files Affected:

- (modified) llvm/lib/Analysis/ValueTracking.cpp (+1-1) 


``````````diff
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index ee4f97f3bf5e0f..78b791d1d3b331 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<Instruction>(L);
     if (!LU)
       continue;
     unsigned Opcode = LU->getOpcode();

``````````

</details>


https://github.com/llvm/llvm-project/pull/74678


More information about the llvm-commits mailing list