[PATCH] D15063: Introduce a range version of std::any_of, and use it in SCEV

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 29 17:35:18 PST 2015


While you're at it can you remove the any_of_range from
tools/llvm-pdbdump/LinePrinter.cpp and use this new version instead?

On Sun, Nov 29, 2015 at 5:27 PM, Sanjoy Das via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> sanjoy created this revision.
> sanjoy added reviewers: dblaikie, pcc.
> sanjoy added a subscriber: llvm-commits.
>
> http://reviews.llvm.org/D15063
>
> Files:
>   include/llvm/ADT/STLExtras.h
>   lib/Analysis/ScalarEvolution.cpp
>
> Index: lib/Analysis/ScalarEvolution.cpp
> ===================================================================
> --- lib/Analysis/ScalarEvolution.cpp
> +++ lib/Analysis/ScalarEvolution.cpp
> @@ -8403,8 +8403,7 @@
>
>    // The only time we can solve this is when we have all constant indices.
>    // Otherwise, we cannot determine the overflow conditions.
> -  if (std::any_of(op_begin(), op_end(),
> -                  [](const SCEV *Op) { return !isa<SCEVConstant>(Op);}))
> +  if (any_of(operands(), [](const SCEV *Op) { return
> !isa<SCEVConstant>(Op); }))
>      return SE.getCouldNotCompute();
>
>    // Okay at this point we know that all elements of the chrec are
> constants and
> @@ -9694,8 +9693,8 @@
>      return false;
>    auto &SCEVPreds = ScevPredsIt->second;
>
> -  return std::any_of(SCEVPreds.begin(), SCEVPreds.end(),
> -                     [N](const SCEVPredicate *I) { return I->implies(N);
> });
> +  return any_of(SCEVPreds,
> +                [N](const SCEVPredicate *I) { return I->implies(N); });
>  }
>
>  const SCEV *SCEVUnionPredicate::getExpr() const { return nullptr; }
> Index: include/llvm/ADT/STLExtras.h
> ===================================================================
> --- include/llvm/ADT/STLExtras.h
> +++ include/llvm/ADT/STLExtras.h
> @@ -371,6 +371,14 @@
>                       std::forward<UnaryPredicate>(P));
>  }
>
> +/// Provide wrappers to std::any_of which take ranges instead of having
> to pass
> +/// begin/end explicitly.
> +template <typename R, class UnaryPredicate>
> +bool any_of(R &&Range, UnaryPredicate &&P) {
> +  return std::any_of(Range.begin(), Range.end(),
> +                     std::forward<UnaryPredicate>(P));
> +}
> +
>
>  //===----------------------------------------------------------------------===//
>  //     Extra additions to <memory>
>
>  //===----------------------------------------------------------------------===//
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
>


-- 
~Craig
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151129/87f6963d/attachment.html>


More information about the llvm-commits mailing list