[LVI] Don't traverse uses when calculating range at use
authorDmitry Makogon <d.makogon@g.nsu.ru>
Fri, 10 Feb 2023 09:00:16 +0000 (16:00 +0700)
committerDmitry Makogon <d.makogon@g.nsu.ru>
Fri, 10 Feb 2023 10:06:36 +0000 (17:06 +0700)
commitc77c186a647b385c291ddabecd70a2b4f84ae342
treeb70942557d389ac8d0af438b6cf850ed577836e6
parent0737770c3e1d5e119148351610c39fb2483c7011
[LVI] Don't traverse uses when calculating range at use

This effectively reverts 5c38c6a and 4f772b0.

A recently introduced LazyValueInfo::getConstantRangeAtUse returns incorrect
ranges for values in certain cases. One such example is described in PR60629.
The issue has something to do with traversing PHI uses of a value transitively.
As nikic pointed out, we're effectively reasoning about values from different
loop iterations.

In the faulting test case, CVP made a miscompilation because the calculated
range for a shift argument was incorrect. It returned empty-set, however it is
clearly not a dead code. CVP then erased the shift instruction because
of empty range.
llvm/lib/Analysis/LazyValueInfo.cpp
llvm/test/Analysis/LazyValueAnalysis/pr60629.ll
llvm/test/Transforms/CorrelatedValuePropagation/cond-at-use.ll