SCEVComplexityCompare's new code was missing SCEVUDivExpr. Implement
authorDan Gohman <gohman@apple.com>
Thu, 7 May 2009 19:23:21 +0000 (19:23 +0000)
committerDan Gohman <gohman@apple.com>
Thu, 7 May 2009 19:23:21 +0000 (19:23 +0000)
the SCEVUDivExpr case.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71173 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ScalarEvolution.cpp

index 1a5ef7ef9589fc5db22e116ded746ac9cc0d82a9..d34b898dbdf6757df453d9d21e5297a2c0780122 100644 (file)
@@ -502,6 +502,20 @@ namespace {
         return LC->getNumOperands() < RC->getNumOperands();
       }
 
+      // Lexicographically compare udiv expressions.
+      if (const SCEVUDivExpr *LC = dyn_cast<SCEVUDivExpr>(LHS)) {
+        const SCEVUDivExpr *RC = cast<SCEVUDivExpr>(RHS);
+        if (operator()(LC->getLHS(), RC->getLHS()))
+          return true;
+        if (operator()(RC->getLHS(), LC->getLHS()))
+          return false;
+        if (operator()(LC->getRHS(), RC->getRHS()))
+          return true;
+        if (operator()(RC->getRHS(), LC->getRHS()))
+          return false;
+        return false;
+      }
+
       // Compare cast expressions by operand.
       if (const SCEVCastExpr *LC = dyn_cast<SCEVCastExpr>(LHS)) {
         const SCEVCastExpr *RC = cast<SCEVCastExpr>(RHS);