Avoid deleting individual instructions until AFTER dead blocks have dropped
[oota-llvm.git] / lib / Transforms / Scalar / InstructionCombining.cpp
index 0812fca6e97994ba07374b10fb1f70c2a55004f1..6032ab956eb674247e05c6f1031ddcfe62893e17 100644 (file)
@@ -124,8 +124,7 @@ Instruction *InstCombiner::visitAdd(BinaryOperator *I) {
   Value *LHS = I->getOperand(0), *RHS = I->getOperand(1);
 
   // Eliminate 'add int %X, 0'
-  if (I->getType()->isIntegral() &&
-      RHS == Constant::getNullValue(I->getType())) {
+  if (RHS == Constant::getNullValue(I->getType())) {
     AddUsesToWorkList(I);         // Add all modified instrs to worklist
     I->replaceAllUsesWith(LHS);
     return I;
@@ -187,7 +186,7 @@ Instruction *InstCombiner::visitSub(BinaryOperator *I) {
   // not used by anyone else...
   //
   if (BinaryOperator *Op1I = dyn_cast<BinaryOperator>(Op1))
-    if (Op1I->use_size() == 1) {
+    if (Op1I->use_size() == 1 && Op1I->getOpcode() == Instruction::Sub) {
       // Swap the two operands of the subexpr...
       Value *IIOp0 = Op1I->getOperand(0), *IIOp1 = Op1I->getOperand(1);
       Op1I->setOperand(0, IIOp1);