[llvm-commits] [llvm] r108855 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp
Dan Gohman
gohman at apple.com
Tue Jul 20 09:53:00 PDT 2010
Author: djg
Date: Tue Jul 20 11:53:00 2010
New Revision: 108855
URL: http://llvm.org/viewvc/llvm-project?rev=108855&view=rev
Log:
Add a fast path for x - x.
Modified:
llvm/trunk/lib/Analysis/ScalarEvolution.cpp
Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=108855&r1=108854&r2=108855&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Tue Jul 20 11:53:00 2010
@@ -2442,6 +2442,10 @@
///
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));
}
More information about the llvm-commits
mailing list