Micro-optimize GroupByComplexity.
authorDan Gohman <gohman@apple.com>
Sun, 29 Aug 2010 15:07:13 +0000 (15:07 +0000)
committerDan Gohman <gohman@apple.com>
Sun, 29 Aug 2010 15:07:13 +0000 (15:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112431 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ScalarEvolution.cpp

index 176de3a2b9e82bc70d1e8ecfa432b901877a1c21..863f8a65409cf4df0c7afa9d93008d0341fdecb9 100644 (file)
@@ -704,8 +704,9 @@ static void GroupByComplexity(SmallVectorImpl<const SCEV *> &Ops,
   if (Ops.size() == 2) {
     // This is the common case, which also happens to be trivially simple.
     // Special case it.
-    if (SCEVComplexityCompare(LI)(Ops[1], Ops[0]))
-      std::swap(Ops[0], Ops[1]);
+    const SCEV *&LHS = Ops[0], *&RHS = Ops[1];
+    if (SCEVComplexityCompare(LI)(RHS, LHS))
+      std::swap(LHS, RHS);
     return;
   }