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}<%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