[PATCH] D65474: [SCEV] Return zero from computeConstantDifference(X, X)
Nikolai Bozhenov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 30 15:53:43 PDT 2019
n.bozhenov added a comment.
In D65474#1607285 <https://reviews.llvm.org/D65474#1607285>, @sanjoy wrote:
> > We use computeConstantDifference in some downstream code, and I was surprised to find out that it fails to compute (X - X) difference, unless X is a SCEVAddExpr.
>
> Can you use `getMinusSCEV` instead (which should DTRT)?
>
> This looks like a small change, having many such cases (especially without unit tests) makes it difficult to refactor code confidently.
Hi Sanjoy,
What I need is to check if two arbitrary SCEV expressions are constant distance apart or not, and compute that difference. That's exactly what computeConstantDifference does (except for the (%x - %x) case). I would be ok to use getMinusSCEV, but it does not do the right thing unfortunately. Given {%x, +, 1}<loop1> and {%x, +, 1}<loop2>, getMinusSCEV crashes instead of returning SCEVCouldNotCompute. And I am not aware of any existing API that checks whether two SCEVs are safe to subtract or not.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D65474/new/
https://reviews.llvm.org/D65474
More information about the llvm-commits
mailing list