git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108855
91177308-0d34-0410-b5e6-
96231b3b80d8
///
const SCEV *ScalarEvolution::getMinusSCEV(const SCEV *LHS,
const SCEV *RHS) {
///
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));
}
// X - Y --> X + -Y
return getAddExpr(LHS, getNegativeSCEV(RHS));
}