diff options
author | Nikolai Bozhenov <nikolai.bozhenov@intel.com> | 2019-08-07 17:38:38 +0000 |
---|---|---|
committer | Nikolai Bozhenov <nikolai.bozhenov@intel.com> | 2019-08-07 17:38:38 +0000 |
commit | 03edcd68dd739cce53256f8573a141b09ea49ae3 (patch) | |
tree | 344dce7c13f382f63e8b50a2b0b34422267b7d37 /llvm/lib/Analysis/ScalarEvolution.cpp | |
parent | a1d20506e771a376e293a61e26842a906487d7ef (diff) | |
download | bcm5719-llvm-03edcd68dd739cce53256f8573a141b09ea49ae3.tar.gz bcm5719-llvm-03edcd68dd739cce53256f8573a141b09ea49ae3.zip |
[SCEV] Return zero from computeConstantDifference(X, X)
Without this patch computeConstantDifference returns None for cases like
these:
computeConstantDifference(%x, %x)
computeConstantDifference({%x,+,16}, {%x,+,16})
Differential Revision: https://reviews.llvm.org/D65474
llvm-svn: 368193
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolution.cpp')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index bc2cfd6fcc4..8552d784c43 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -9833,6 +9833,10 @@ Optional<APInt> ScalarEvolution::computeConstantDifference(const SCEV *More, // We avoid subtracting expressions here because this function is usually // fairly deep in the call stack (i.e. is called many times). + // X - X = 0. + if (More == Less) + return APInt(getTypeSizeInBits(More->getType()), 0); + if (isa<SCEVAddRecExpr>(Less) && isa<SCEVAddRecExpr>(More)) { const auto *LAR = cast<SCEVAddRecExpr>(Less); const auto *MAR = cast<SCEVAddRecExpr>(More); |