[PATCH] D101829: [SCEV] By more careful when traversing phis in isImpliedViaMerge.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 5 13:08:29 PDT 2021


fhahn added a comment.

In D101829#2739843 <https://reviews.llvm.org/D101829#2739843>, @reames wrote:

> I'm confused.
>
> On this example:
> inner:
>
>   %x = phi i32 [ -1, %outer.header ], [ %call, %inner ]
>   %call = call i32 @match()
>   %inner.cond = icmp sgt i32 %call, -1
>   br i1 %inner.cond, label %inner, label %outer.exiting.1
>
> outer.exiting.1:
>
>   %x.lcssa = phi i32 [ %x, %inner ]
>
> The value of %x *is* always signed less than or equal to -1.  On the last iteration, %call might not be, but the value used in the x.lcssa is the value of the phi, not of the call.  Thus, concluding that %x.lcssa <=s -1 seems entirely correct?

I might be glancing over something, but aren't we continuing the loop if `%call >s -1` and exit if `call <=s -1?

So in the iteration before we exit, `%call >s -1`, hence `%x >s -1` in the last iteration. In the last iteration, `%call <=s -1`, but `%x` still has the value from the previous iteration.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101829



More information about the llvm-commits mailing list