[PATCH] D26877: Minor fixes in Loop Strength Reduction

Wei Mi via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 21 14:33:45 PST 2016


We found a testcase related with item3 and the patch here fixed it. I
will contribute a testcase soon. Thanks for the patch!

Thanks,
Wei.


On Mon, Nov 21, 2016 at 2:18 PM, Evgeny Stupachenko <evstupac at gmail.com> wrote:
> evstupac updated this revision to Diff 78784.
> evstupac added a comment.
>
> "2. Debug print: ..." committed separately.
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D26877
>
> Files:
>   lib/Transforms/Scalar/LoopStrengthReduce.cpp
>
>
> Index: lib/Transforms/Scalar/LoopStrengthReduce.cpp
> ===================================================================
> --- lib/Transforms/Scalar/LoopStrengthReduce.cpp
> +++ lib/Transforms/Scalar/LoopStrengthReduce.cpp
> @@ -1674,7 +1674,7 @@
>    SmallPtrSet<Use*, MaxChains> IVIncSet;
>
>    void OptimizeShadowIV();
> -  bool FindIVUserForCond(ICmpInst *Cond, IVStrideUse *&CondUse);
> +  bool FindIVUserForInst(Instruction *Inst, IVStrideUse *&InstUse);
>    ICmpInst *OptimizeMax(ICmpInst *Cond, IVStrideUse* &CondUse);
>    void OptimizeLoopTermCond();
>
> @@ -1896,15 +1896,15 @@
>    }
>  }
>
> -/// If Cond has an operand that is an expression of an IV, set the IV user and
> +/// If Inst has an operand that is an expression of an IV, set the IV user and
>  /// stride information and return true, otherwise return false.
> -bool LSRInstance::FindIVUserForCond(ICmpInst *Cond, IVStrideUse *&CondUse) {
> +bool LSRInstance::FindIVUserForInst(Instruction *Inst, IVStrideUse *&InstUse) {
>    for (IVStrideUse &U : IU)
> -    if (U.getUser() == Cond) {
> +    if (U.getUser() == Inst) {
>        // NOTE: we could handle setcc instructions with multiple uses here, but
>        // InstCombine does it as well for simple uses, it's not clear that it
>        // occurs enough in real life to handle.
> -      CondUse = &U;
> +      InstUse = &U;
>        return true;
>      }
>    return false;
> @@ -2114,7 +2114,7 @@
>      // Search IVUsesByStride to find Cond's IVUse if there is one.
>      IVStrideUse *CondUse = nullptr;
>      ICmpInst *Cond = cast<ICmpInst>(TermBr->getCondition());
> -    if (!FindIVUserForCond(Cond, CondUse))
> +    if (!FindIVUserForInst(Cond, CondUse))
>        continue;
>
>      // If the trip count is computed in terms of a max (due to ScalarEvolution
> @@ -4144,9 +4144,10 @@
>      for (const SCEV *Reg : RegUses) {
>        if (Taken.count(Reg))
>          continue;
> -      if (!Best)
> +      if (!Best) {
>          Best = Reg;
> -      else {
> +        BestNum = RegUses.getUsedByIndices(Reg).count();
> +      } else {
>          unsigned Count = RegUses.getUsedByIndices(Reg).count();
>          if (Count > BestNum) {
>            Best = Reg;
>
>


More information about the llvm-commits mailing list