[llvm-dev] LazyValueInfo vs ScalarEvolution

Hongbin Zheng via llvm-dev llvm-dev at lists.llvm.org
Mon Jul 24 14:16:26 PDT 2017


Thanks, maybe we could use ScalarEvolution in LazyValueInfo if it is
available?

On Mon, Jul 24, 2017 at 1:44 PM, John Regehr via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> Since they are different static analyses there's no reason to expect them
> to agree, but they should both be conservative. In other words, if you like
> you can compute the intersection of the two ConstantRanges and the result
> should still be an overapproximation of the values that will occur at run
> time.
>
> John
>
>
>
>
> On 07/24/2017 02:34 PM, Hongbin Zheng via llvm-dev wrote:
>
>> 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
>>
>>
>>
>>
>>
>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>>
>> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170724/09139703/attachment.html>


More information about the llvm-dev mailing list