Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ValueTracking] Use BinaryOperator instead of Operator in matchSimpleRecurrence. #74678

Merged
merged 2 commits into from
Dec 7, 2023

Conversation

topperc
Copy link
Collaborator

@topperc topperc commented Dec 6, 2023

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. We can only match a BinaryOperator so use that instead.

…urrence.

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.
@llvmbot
Copy link
Collaborator

llvmbot commented Dec 6, 2023

@llvm/pr-subscribers-llvm-analysis

Author: Craig Topper (topperc)

Changes

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 --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();

@topperc topperc changed the title [ValueTracking] Use Instruction instead of Operator in matchSimpleRecurrence. [ValueTracking] Use BinaryOperator instead of Operator in matchSimpleRecurrence. Dec 7, 2023
Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@preames preames left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@topperc topperc merged commit 32ec5fb into llvm:main Dec 7, 2023
3 of 4 checks passed
@topperc topperc deleted the pr/match-simple branch December 7, 2023 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants