[llvm-dev] vrp
Anastasiya Ruzhanskaya via llvm-dev
llvm-dev at lists.llvm.org
Mon Aug 7 03:38:51 PDT 2017
When I am printing, I call getConstantRange and this method internally
calls : gerValueInBlock()
LVILatticeVal LazyValueInfoImpl::getValueInBlock(Value
<https://llvm.org/doxygen/classllvm_1_1Value.html> *V, BasicBlock
<https://llvm.org/doxygen/classllvm_1_1BasicBlock.html> *BB,
Instruction <https://llvm.org/doxygen/classllvm_1_1Instruction.html>
*CxtI) {
DEBUG
<https://llvm.org/doxygen/Debug_8h.html#aef41e8aaf4c60819b30faf396cdf4978>(
dbgs
<https://llvm.org/doxygen/namespacellvm.html#a7c46c742c31be54870e2038048e6b391>()
<< "LVI Getting block end value " << *V << " at '"
<< BB->getName
<https://llvm.org/doxygen/classllvm_1_1Value.html#adb5c319f5905c1d3ca9eb5df546388c5>()
<< "'\n");
assert
<https://llvm.org/doxygen/SILowerControlFlow_8cpp.html#a4868c5d81c5ccc98c47aeab6244346a0>(BlockValueStack.empty()
&& BlockValueSet.empty());
if (!hasBlockValue(V, BB)) {
pushBlockValue(std::make_pair(BB, V));
solve
<https://llvm.org/doxygen/namespacellvm_1_1PBQP_1_1RegAlloc.html#a57e1115cb3c891254a6e675437c1a40c>
();
}
<...>
}
which internally inserts the pair, so it seems that the informations, that
I am printing , is in cache.
2017-08-07 12:05 GMT+02:00 Anastasiya Ruzhanskaya <
anastasiya.ruzhanskaya at frtk.ru>:
> I am primarily interested in phi nodes and their induction variables, in
> ValueTracking file there is an analysis of them, but if the upper bound is
> inf, it is not working?
>
> 2017-08-07 11:41 GMT+02:00 Anastasiya Ruzhanskaya <
> anastasiya.ruzhanskaya at frtk.ru>:
>
>> So, it is not supported to determine by this instruction : %cmp = icmp
>> slt i32 %i.03, 99,
>> that %i.03 = phi i32 [ 0, %entry ], [ %inc, %for.body ] has
>> a range [0, 99]?
>>
>> And what is then a correct way to get such an info, that you sent ( with
>> more specified ranges)? ...seems that appropriate method for it is not in
>> LazyValueInfo class.
>>
>> 2017-08-07 11:34 GMT+02:00 Davide Italiano <davide at freebsd.org>:
>>
>>> On Mon, Aug 7, 2017 at 2:14 AM, Anastasiya Ruzhanskaya via llvm-dev
>>> <llvm-dev at lists.llvm.org> wrote:
>>> > I am trying to print it like this (maybe here is smth wrong?)
>>> >
>>> >
>>> > LazyValueInfo &LV = getAnalysis<LazyValueInfoWrapp
>>> erPass>().getLVI();
>>> > DominatorTree &DT =
>>> > getAnalysis<DominatorTreeWrapperPass>().getDomTree();
>>> > LV.printLVI(F, DT, llvm::outs());
>>>
>>> The value analysis in llvm is lazy (hence, LVI), so you're trying to
>>> print an empty cache, I guess.
>>>
>>> > for (BasicBlock &BB : F) {
>>> > for (Instruction &I : BB) {
>>> > if (Value* v = dyn_cast<Value>(&I))
>>> > if (v->getType()->isIntegerTy()) {
>>> > ConstantRange r = LV.getConstantRange(v, &BB, &I);
>>> > I.dump();
>>> > printf("LOWER VALUE : %llu\n",r.getLower().getRawData());
>>> > printf("UPPER VALUE : %llu\n",r.getUpper().getRawData());
>>> > }
>>> > }
>>>
>>> About your other question, "the value range pass was not able to
>>> determine any size, even of the induction variable, is it a correct
>>> behavior?". Yes, returning a conservative answer is always correct,
>>> but not optimal.
>>>
>>> As reference, a more sophisticated range analysis finds the following
>>> ranges for your IR:
>>>
>>> [0, +inf] %i.03 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
>>> [0, +inf] %s.02 = phi i32 [ 0, %entry ], [ %add2, %for.body ]
>>> [0, +inf] %j.01 = phi i32 [ 0, %entry ], [ %add1, %for.body ]
>>> [0, +inf] %add = add nsw i32 %j.01, %i.03
>>> [1, +inf] %add1 = add nsw i32 %add, 1
>>> [1, +inf] %add2 = add nsw i32 %s.02, %add1
>>> [1, +inf] %inc = add nsw i32 %i.03, 1
>>> [2, +inf] %add3 = add nsw i32 %add2, %add1
>>>
>>>
>>> --
>>> Davide
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170807/0fd979d2/attachment.html>
More information about the llvm-dev
mailing list