[PATCH] D105723: [LSR] Do not hoist IV if it is not post increment case. PR43678

Serguei Katkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 15 20:40:07 PDT 2021


skatkov added a comment.

ok, after some additional investigation it looks like with my patch I effectively disabled hoisting at all.
First of all in places which I updated we are trying to hoist loop increment use of IV.

And it seems loop increment use cannot be marked as post-inc use.
There are two places in the code where use is marked as post-inc:

1. In IVUsers::AddUsersImpl  it is marked under condition IVUseShouldUsePostIncValue is true, where the first check

  if (L->contains(User))
    return false;

It means that for IV increment (which is always located in a loop) we always returns false.

2.

  void IVStrideUse::transformToPostInc(const Loop *L) {
    PostIncLoops.insert(L);
  }

The only use of this function is CondUse->transformToPostInc(L); in LSRInstance::OptimizeLoopTermCond, so we mark condition which is not increment of IV.

So increment of IV cannot be marked as post-inc use and my patch just completely disable hoisting...

I will try to look into the history for the reason why this hoisting was added. If we want to complete it, probably we can check if there is a IV increment user which is planned to be updated by LSR and forbid hoisting of such increment. But it will add a complexity and interaction between LSR and expander.


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

https://reviews.llvm.org/D105723



More information about the llvm-commits mailing list