[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp

Chris Lattner lattner at cs.uiuc.edu
Sun Jun 27 17:52:01 PDT 2004


Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.214 -> 1.215

---
Log message:

Implement InstCombine/add.ll:test21


---
Diffs of the changes:  (+6 -1)

Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.214 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.215
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.214	Fri Jun 18 01:07:51 2004
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Sun Jun 27 17:51:36 2004
@@ -1520,10 +1520,15 @@
       if (BinaryOperator *BO = dyn_cast<BinaryOperator>(Op0)) {
         switch (BO->getOpcode()) {
         case Instruction::Add:
-          if (CI->isNullValue()) {
+          // Replace ((add A, B) != C) with (A != C-B) if B & C are constants.
+          if (ConstantInt *BOp1C = dyn_cast<ConstantInt>(BO->getOperand(1))) {
+            return new SetCondInst(I.getOpcode(), BO->getOperand(0),
+                                   ConstantExpr::getSub(CI, BOp1C));
+          } else if (CI->isNullValue()) {
             // Replace ((add A, B) != 0) with (A != -B) if A or B is
             // efficiently invertible, or if the add has just this one use.
             Value *BOp0 = BO->getOperand(0), *BOp1 = BO->getOperand(1);
+            
             if (Value *NegVal = dyn_castNegVal(BOp1))
               return new SetCondInst(I.getOpcode(), BOp0, NegVal);
             else if (Value *NegVal = dyn_castNegVal(BOp0))





More information about the llvm-commits mailing list