[llvm] r256338 - [SCEV] Fix getLoopBackedgeTakenCounts

JF Bastien via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 23 10:22:36 PST 2015


Seems broken, I think r256338 fixes it.

On Wed, Dec 23, 2015 at 9:48 AM, Sanjoy Das via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: sanjoy
> Date: Wed Dec 23 11:48:14 2015
> New Revision: 256338
>
> URL: http://llvm.org/viewvc/llvm-project?rev=256338&view=rev
> Log:
> [SCEV] Fix getLoopBackedgeTakenCounts
>
> The way `getLoopBackedgeTakenCounts` is written right now isn't
> correct. It will try to compute and store the BE counts of a Loop
>  #{child loop} number of times (which may be zero).
>
> 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=256338&r1=256337&r2=256338&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
> +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Wed Dec 23 11:48:14 2015
> @@ -9439,23 +9439,22 @@ static void replaceSubString(std::string
>  /// getLoopBackedgeTakenCounts - Helper method for verifyAnalysis.
>  static void
>  getLoopBackedgeTakenCounts(Loop *L, VerifyMap &Map, ScalarEvolution &SE) {
> -  for (Loop::reverse_iterator I = L->rbegin(), E = L->rend(); I != E;
> ++I) {
> -    getLoopBackedgeTakenCounts(*I, Map, SE); // recurse.
> +  std::string &S = Map[L];
> +  if (S.empty()) {
> +    raw_string_ostream OS(S);
> +    SE.getBackedgeTakenCount(L)->print(OS);
>
> -    std::string &S = Map[L];
> -    if (S.empty()) {
> -      raw_string_ostream OS(S);
> -      SE.getBackedgeTakenCount(L)->print(OS);
> -
> -      // false and 0 are semantically equivalent. This can happen in dead
> loops.
> -      replaceSubString(OS.str(), "false", "0");
> -      // Remove wrap flags, their use in SCEV is highly fragile.
> -      // FIXME: Remove this when SCEV gets smarter about them.
> -      replaceSubString(OS.str(), "<nw>", "");
> -      replaceSubString(OS.str(), "<nsw>", "");
> -      replaceSubString(OS.str(), "<nuw>", "");
> -    }
> +    // false and 0 are semantically equivalent. This can happen in dead
> loops.
> +    replaceSubString(OS.str(), "false", "0");
> +    // Remove wrap flags, their use in SCEV is highly fragile.
> +    // FIXME: Remove this when SCEV gets smarter about them.
> +    replaceSubString(OS.str(), "<nw>", "");
> +    replaceSubString(OS.str(), "<nsw>", "");
> +    replaceSubString(OS.str(), "<nuw>", "");
>    }
> +
> +  for (auto *L : reverse(*L))
> +    getLoopBackedgeTakenCounts(L, Map, SE); // recurse.
>  }
>
>  void ScalarEvolution::verify() const {
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151223/a3dd0ee6/attachment.html>


More information about the llvm-commits mailing list