[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 13:07:23 PDT 2019
n.bozhenov created this revision.
n.bozhenov added reviewers: sanjoy, llvm-commits.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
Without this patch computeConstantDifference returns None for cases like
these:
computeConstantDifference(%x, %x)
computeConstantDifference({%x,+,16}, {%x,+,16})
Repository:
rL LLVM
https://reviews.llvm.org/D65474
Files:
llvm/lib/Analysis/ScalarEvolution.cpp
Index: llvm/lib/Analysis/ScalarEvolution.cpp
===================================================================
--- llvm/lib/Analysis/ScalarEvolution.cpp
+++ llvm/lib/Analysis/ScalarEvolution.cpp
@@ -9833,6 +9833,10 @@
// 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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65474.212419.patch
Type: text/x-patch
Size: 629 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190730/52de7733/attachment.bin>
More information about the llvm-commits
mailing list