[llvm-dev] SCEV related question

Sanjoy Das via llvm-dev llvm-dev at lists.llvm.org
Sun Aug 25 13:39:34 PDT 2019


On Sun, Aug 25, 2019 at 4:49 AM vivek pandya via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
>
> Hello,
>
> I am first time paying with SCEV codebase.
> I am trying to find out why ScalarEvolution is not able to give correct back edge taken count for an expression.
>
> So in my case flow reaches to howFarToZero() and in that function, I have following expressions as SCEV
>
> Start = (15 + (-1 * %i) (which is set to Distance SCEV)
> Step = 1
>
> now, first of all, should I expect Start as ConstantSCEV (15) instead of the whole expression
> the problem here is getUnsignedRangeMax(Distance) returns very large number because of -1 in the SCEV.

Given you have have above, in howFarToZero SCEV is reasoning about the
loop as if it were:

unsigned i = ...;
unsigned Start = 15 - i;
while (Start != 0) {
  unsigned Step = 1;
  Start = Start + Step;
}

> How we can make this work? Here we can clearly say that after 15 steps this expression will be 0

and so I don't think this assertion ("after 15 steps this expression
will be 0") is correct.

If you post a minimal example we can try to figure out if SCEV can be
smarter here.

-- Sanjoy

> and thus we have a value for backedge taken count.
>
> Any help will be appriciated.
>
> Thanks,
> Vivek
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


More information about the llvm-dev mailing list