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

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 6 15:47:43 PST 2023


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

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.

>From dbde4164cdc33f8b728c22579a8a93b4289c616b Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Wed, 6 Dec 2023 15:40:53 -0800
Subject: [PATCH] [ValueTracking] Use Instruction instead of Operator in
 matchSimpleRecurrence.

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.
---
 llvm/lib/Analysis/ValueTracking.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index ee4f97f3bf5e0..78b791d1d3b33 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();



More information about the llvm-commits mailing list