[llvm-dev] LazyValueInfo vs ScalarEvolution

Hongbin Zheng via llvm-dev llvm-dev at lists.llvm.org
Mon Jul 24 13:34:33 PDT 2017


Hi,

Both LazyValueInfo and ScalarEvolution can calculate a constant range for
an LLVM Value.
I found that some times they do not agree, may be I interpreted them
incorrectly

For example in the following IR:

bb85:                                             ; preds = %bb85, %bb73
  %tmp86 = phi i32 [ 1, %bb73 ], [ %tmp95, %bb85 ]
  %tmp95 = add nsw i32 %tmp86, 1
  %tmp96 = icmp slt i32 %tmp95, 20
  br i1 %tmp96, label %bb85, label %bb97

LazyValueInfo give:

POP   %tmp86 = phi i32 [ 1, %bb73 ], [ %tmp95, %bb85 ] in bb85 =
constantrange<-2147483648, 20>

While ScalarEvolution give:

 %tmp86 = phi i32 [ 1, %bb73 ], [ %tmp95, %bb85 ]
  -->  {1,+,1}<nuw><nsw><%bb85> U: [1,20) S: [1,20)             Exits: 19
            LoopDispositions: { %bb85: Computable, %bb73: Variant, %bb46:
Variant }

In this example, the range of %tmp86 is <-2147483648, 20> from
LazyValueInfo, but it is [1,20) from ScalarEvolution.

How can I interpret these results?
Is there a way to get [0, 20) for %tmp86 in LazyValueInfo?

Thanks
Hongbin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170724/e9a9a8ee/attachment.html>


More information about the llvm-dev mailing list