[llvm] r208237 - do not collect undef terms

Hal Finkel hfinkel at anl.gov
Wed May 7 12:09:28 PDT 2014


----- Original Message -----
> From: "Sebastian Pop" <spop at codeaurora.org>
> To: llvm-commits at cs.uiuc.edu
> Sent: Wednesday, May 7, 2014 2:00:32 PM
> Subject: [llvm] r208237 - do not collect undef terms
> 
> Author: spop
> Date: Wed May  7 14:00:32 2014
> New Revision: 208237
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=208237&view=rev
> Log:
> do not collect undef terms

Why? What does this affect? (Is there a regression test?)

 -Hal

> 
> Modified:
>     llvm/trunk/lib/Analysis/ScalarEvolution.cpp
> 
> Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=208237&r1=208236&r2=208237&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
> +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Wed May  7 14:00:32
> 2014
> @@ -6816,6 +6816,40 @@ const SCEV *SCEVAddRecExpr::getNumIterat
>  }
>  
>  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;
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 

-- 
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory



More information about the llvm-commits mailing list