[PATCH] D103816: [SimpleLoopUnswich] Fix a bug on ComputeUnswitchedCost with partial unswitch

Sanne Wouda via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 22 03:50:29 PDT 2021


sanwou01 added a comment.

I think I managed to figure out what's going on here in the end, but it would help to explain what the bug is in the commit message, something like:

> The costs of non-duplicated blocks are substracted from the total LoopCost, so anything that is duplicated should *not* be counted.





================
Comment at: llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp:2876-2881
           if (PartialIVInfo.KnownValue->isOneValue() &&
-              SuccBB == BI.getSuccessor(1))
+              SuccBB == BI.getSuccessor(0))
             continue;
           else if (!PartialIVInfo.KnownValue->isOneValue() &&
-                   SuccBB == BI.getSuccessor(0))
+                   SuccBB == BI.getSuccessor(1))
             continue;
----------------
Agreed here!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103816/new/

https://reviews.llvm.org/D103816



More information about the llvm-commits mailing list