Fix InstCombine/2006-04-01-InfLoop.ll
authorChris Lattner <sabre@nondot.org>
Sat, 1 Apr 2006 22:05:01 +0000 (22:05 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 1 Apr 2006 22:05:01 +0000 (22:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27330 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp

index ecdb62b9757087e554d30a4295737a06267589fd..c5c2a5e3c57ab80bb865218c625320c288acd59c 100644 (file)
@@ -3008,7 +3008,8 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
     } else if (Op0I->getOpcode() == Instruction::And && Op0I->hasOneUse()) {
       if (Op0I->getOperand(0) == Op1)                      // (A&B)^A -> (B&A)^A
         Op0I->swapOperands();
-      if (Op0I->getOperand(1) == Op1) {                    // (B&A)^A == ~B & A
+      if (Op0I->getOperand(1) == Op1 &&                    // (B&A)^A == ~B & A
+          !isa<ConstantInt>(Op1)) {  // Canonical form is (B&C)^C
         Instruction *N = BinaryOperator::createNot(Op0I->getOperand(0), "tmp");
         InsertNewInstBefore(N, I);
         return BinaryOperator::createAnd(N, Op1);