]> granicus.if.org Git - llvm/commitdiff
NewGVN: Cleanup conditions to match reality
authorDaniel Berlin <dberlin@dberlin.org>
Tue, 31 Jan 2017 22:32:01 +0000 (22:32 +0000)
committerDaniel Berlin <dberlin@dberlin.org>
Tue, 31 Jan 2017 22:32:01 +0000 (22:32 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293707 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/NewGVN.cpp

index 7a0e076abfcf3e94d246be785ad499d496c27ea5..4fccaff285bf85841216a27030db8ad7b3e1685b 100644 (file)
@@ -595,24 +595,19 @@ const Expression *NewGVN::createExpression(Instruction *I,
     }
     E->setOpcode((CI->getOpcode() << 8) | Predicate);
     // TODO: 25% of our time is spent in SimplifyCmpInst with pointer operands
-    // TODO: Since we noop bitcasts, we may need to check types before
-    // simplifying, so that we don't end up simplifying based on a wrong
-    // type assumption. We should clean this up so we can use constants of the
-    // wrong type
-
     assert(I->getOperand(0)->getType() == I->getOperand(1)->getType() &&
            "Wrong types on cmp instruction");
-    if ((E->getOperand(0)->getType() == I->getOperand(0)->getType() &&
-         E->getOperand(1)->getType() == I->getOperand(1)->getType())) {
-      Value *V = SimplifyCmpInst(Predicate, E->getOperand(0), E->getOperand(1),
+    assert ((E->getOperand(0)->getType() == I->getOperand(0)->getType() &&
+             E->getOperand(1)->getType() == I->getOperand(1)->getType()));
+    Value *V = SimplifyCmpInst(Predicate, E->getOperand(0), E->getOperand(1),
                                  *DL, TLI, DT, AC);
-      if (const Expression *SimplifiedE = checkSimplificationResults(E, I, V))
-        return SimplifiedE;
-    }
+    if (const Expression *SimplifiedE = checkSimplificationResults(E, I, V))
+      return SimplifiedE;
   } else if (isa<SelectInst>(I)) {
     if (isa<Constant>(E->getOperand(0)) ||
-        (E->getOperand(1)->getType() == I->getOperand(1)->getType() &&
-         E->getOperand(2)->getType() == I->getOperand(2)->getType())) {
+        E->getOperand(0) == E->getOperand(1)){ 
+      assert (E->getOperand(1)->getType() == I->getOperand(1)->getType() &&
+              E->getOperand(2)->getType() == I->getOperand(2)->getType());
       Value *V = SimplifySelectInst(E->getOperand(0), E->getOperand(1),
                                     E->getOperand(2), *DL, TLI, DT, AC);
       if (const Expression *SimplifiedE = checkSimplificationResults(E, I, V))