diff options
author | Ricardo Jesus <rjj@nvidia.com> | 2025-06-16 09:12:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-16 09:12:42 +0100 |
commit | cca454b54c7d58930e261c7fa72f44a1a8976997 (patch) | |
tree | f68e954266d716e356e9ca83bbc4ff1fae0e2eac /llvm/lib/Analysis/ValueTracking.cpp | |
parent | fbade95ebf2bc959fada5206e47f792a2090d72e (diff) | |
download | llvm-cca454b54c7d58930e261c7fa72f44a1a8976997.zip llvm-cca454b54c7d58930e261c7fa72f44a1a8976997.tar.gz llvm-cca454b54c7d58930e261c7fa72f44a1a8976997.tar.bz2 |
[ValueTracking] Remove opcode whitelist from matchSimpleRecurrence. (#144031)
This also patches HashRecognize to avoid it mishandling some opcodes.
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 40 |
1 files changed, 11 insertions, 29 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index e7a1f07..d39efb2 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -9071,6 +9071,7 @@ bool llvm::matchSimpleRecurrence(const PHINode *P, BinaryOperator *&BO, // Handle the case of a simple two-predecessor recurrence PHI. // There's a lot more that could theoretically be done here, but // this is sufficient to catch some interesting cases. + // TODO: Expand list -- gep, uadd.sat etc. if (P->getNumIncomingValues() != 2) return false; @@ -9081,35 +9082,16 @@ bool llvm::matchSimpleRecurrence(const PHINode *P, BinaryOperator *&BO, if (!LU) continue; unsigned Opcode = LU->getOpcode(); - - switch (Opcode) { - default: - continue; - // TODO: Expand list -- xor, gep, uadd.sat etc. - case Instruction::LShr: - case Instruction::AShr: - case Instruction::Shl: - case Instruction::Add: - case Instruction::Sub: - case Instruction::UDiv: - case Instruction::URem: - case Instruction::And: - case Instruction::Or: - case Instruction::Mul: - case Instruction::FMul: { - Value *LL = LU->getOperand(0); - Value *LR = LU->getOperand(1); - // Find a recurrence. - if (LL == P) - L = LR; - else if (LR == P) - L = LL; - else - continue; // Check for recurrence with L and R flipped. - - break; // Match! - } - }; + Value *LL = LU->getOperand(0); + Value *LR = LU->getOperand(1); + + // Find a recurrence. + if (LL == P) + L = LR; + else if (LR == P) + L = LL; + else + continue; // Check for recurrence with L and R flipped. // We have matched a recurrence of the form: // %iv = [R, %entry], [%iv.next, %backedge] |