Implement xor.ll:test22
authorChris Lattner <sabre@nondot.org>
Fri, 6 May 2005 02:07:39 +0000 (02:07 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 6 May 2005 02:07:39 +0000 (02:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21713 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp

index 4d96cbfcceab6124937b0d80c16ea38233cc2e87..6824c345524b19e48e2fb93f727feb442a93d3bf 100644 (file)
@@ -3550,6 +3550,15 @@ Instruction *InstCombiner::visitCastInst(CastInst &CI) {
                              ->getOpcode(), Op0c, Op1c);
           }
         }
+
+        // cast (xor bool X, true) to int  --> xor (cast bool X to int), 1
+        if (SrcBitSize == 1 && SrcI->getOpcode() == Instruction::Xor &&
+            Op1 == ConstantBool::True &&
+            (!Op0->hasOneUse() || !isa<SetCondInst>(Op0))) {
+          Value *New = InsertOperandCastBefore(Op0, DestTy, &CI);
+          return BinaryOperator::createXor(New,
+                                           ConstantInt::get(CI.getType(), 1));
+        }
         break;
       case Instruction::Shl:
         // Allow changing the sign of the source operand.  Do not allow changing