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

Nick Lewycky nicholas at mxc.ca
Sun Oct 22 15:23:12 PDT 2006



Changes in directory llvm/lib/Transforms/Scalar:

PredicateSimplifier.cpp updated: 1.23 -> 1.24
---
Log message:

Fix similar missing optimization opportunity in XOR.


---
Diffs of the changes:  (+22 -13)

 PredicateSimplifier.cpp |   35 ++++++++++++++++++++++-------------
 1 files changed, 22 insertions(+), 13 deletions(-)


Index: llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp
diff -u llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.23 llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.24
--- llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.23	Sun Oct 22 16:38:24 2006
+++ llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp	Sun Oct 22 17:22:58 2006
@@ -349,19 +349,28 @@
           }
         } break;
         case Instruction::Xor: {
-          ConstantIntegral *CI = dyn_cast<ConstantIntegral>(V1);
-	  if (!CI) break;
-          if (CI->isAllOnesValue()) {
-            if (BO->getOperand(0) == V1)
-              add(Opcode, ConstantBool::getFalse(), BO->getOperand(1), false);
-            if (BO->getOperand(1) == V1)
-              add(Opcode, ConstantBool::getFalse(), BO->getOperand(0), false);
-          }
-          if (CI->isNullValue()) {
-            if (BO->getOperand(0) == ConstantBool::getTrue())
-              add(Opcode, ConstantBool::getTrue(), BO->getOperand(1), false);
-            if (BO->getOperand(1) == ConstantBool::getTrue())
-              add(Opcode, ConstantBool::getTrue(), BO->getOperand(0), false);
+          if (ConstantIntegral *CI = dyn_cast<ConstantIntegral>(V1)) {
+            const Type *Ty = BO->getType();
+            if (CI->isAllOnesValue()) {
+              if (BO->getOperand(0) == V1)
+                add(Opcode, Constant::getNullValue(Ty),
+                    BO->getOperand(1), false);
+              if (BO->getOperand(1) == V1)
+                add(Opcode, Constant::getNullValue(Ty),
+                    BO->getOperand(0), false);
+            }
+            if (CI->isNullValue()) {
+              ConstantIntegral *Op0 =
+                  dyn_cast<ConstantIntegral>(BO->getOperand(0));
+              ConstantIntegral *Op1 =
+                  dyn_cast<ConstantIntegral>(BO->getOperand(1));
+              if (Op0 && Op0->isAllOnesValue())
+                add(Opcode, ConstantIntegral::getAllOnesValue(Ty),
+                    BO->getOperand(1), false);
+              if (Op1 && Op1->isAllOnesValue())
+                add(Opcode, ConstantIntegral::getAllOnesValue(Ty),
+                    BO->getOperand(0), false);
+            }
           }
         } break;
         default:






More information about the llvm-commits mailing list