diff options
author | Sebastian Pop <spop@codeaurora.org> | 2014-05-07 19:00:32 +0000 |
---|---|---|
committer | Sebastian Pop <spop@codeaurora.org> | 2014-05-07 19:00:32 +0000 |
commit | a7d3d6ab9f3fce911b1ac0183423a3d598ead023 (patch) | |
tree | 3e9a6e3104dafe24acc4e2449c39c86848ec2d65 /llvm/lib/Analysis | |
parent | 5f2fd4b22a3509a9b4af57f90f111cff062d3ad4 (diff) | |
download | bcm5719-llvm-a7d3d6ab9f3fce911b1ac0183423a3d598ead023.tar.gz bcm5719-llvm-a7d3d6ab9f3fce911b1ac0183423a3d598ead023.zip |
do not collect undef terms
llvm-svn: 208237
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 7d84dbee5c5..c44c13b04fc 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -6816,6 +6816,40 @@ const SCEV *SCEVAddRecExpr::getNumIterationsInRange(ConstantRange Range, } namespace { +struct FindUndefs { + bool Found; + FindUndefs() : Found(false) {} + + bool follow(const SCEV *S) { + if (const SCEVUnknown *C = dyn_cast<SCEVUnknown>(S)) { + if (isa<UndefValue>(C->getValue())) + Found = true; + } else if (const SCEVConstant *C = dyn_cast<SCEVConstant>(S)) { + if (isa<UndefValue>(C->getValue())) + Found = true; + } + + // Keep looking if we haven't found it yet. + return !Found; + } + bool isDone() const { + // Stop recursion if we have found an undef. + return Found; + } +}; +} + +// Return true when S contains at least an undef value. +static inline bool +containsUndefs(const SCEV *S) { + FindUndefs F; + SCEVTraversal<FindUndefs> ST(F); + ST.visitAll(S); + + return F.Found; +} + +namespace { // Collect all steps of SCEV expressions. struct SCEVCollectStrides { ScalarEvolution &SE; @@ -6841,7 +6875,8 @@ struct SCEVCollectTerms { bool follow(const SCEV *S) { if (isa<SCEVUnknown>(S) || isa<SCEVConstant>(S) || isa<SCEVMulExpr>(S)) { - Terms.push_back(S); + if (!containsUndefs(S)) + Terms.push_back(S); // Stop recursion: once we collected a term, do not walk its operands. return false; |