diff options
author | Dan Gohman <gohman@apple.com> | 2010-07-20 16:53:00 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-07-20 16:53:00 +0000 |
commit | eb4152c192ad226a1dee825f1433277e1851edbc (patch) | |
tree | 619be4a0052cd661fcfc1126487fd40be5773f90 /lib/Analysis/ScalarEvolution.cpp | |
parent | 08993c03abed359171d12b50ab38da0ac331cfb7 (diff) |
Add a fast path for x - x.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108855 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ScalarEvolution.cpp')
-rw-r--r-- | lib/Analysis/ScalarEvolution.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index f0bc9360b1..179aa8867d 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -2442,6 +2442,10 @@ const SCEV *ScalarEvolution::getNotSCEV(const SCEV *V) { /// const SCEV *ScalarEvolution::getMinusSCEV(const SCEV *LHS, const SCEV *RHS) { + // Fast path: X - X --> 0. + if (LHS == RHS) + return getConstant(LHS->getType(), 0); + // X - Y --> X + -Y return getAddExpr(LHS, getNegativeSCEV(RHS)); } |