Implement xform: (X != 0) -> (bool)X
authorChris Lattner <sabre@nondot.org>
Sun, 1 Jun 2003 03:35:25 +0000 (03:35 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 1 Jun 2003 03:35:25 +0000 (03:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6506 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp

index f78f6750ef65b9e3066dd964cefc7d52192ac438..21c58b696e0c42a3abef377d37f4a5c41bd8504f 100644 (file)
@@ -682,6 +682,9 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) {
   // integers at the end of their ranges...
   //
   if (ConstantInt *CI = dyn_cast<ConstantInt>(Op1)) {
+    if (CI->isNullValue() && I.getOpcode() == Instruction::SetNE)
+      return new CastInst(Op0, Type::BoolTy, I.getName());
+
     // Check to see if we are comparing against the minimum or maximum value...
     if (CI->isMinValue()) {
       if (I.getOpcode() == Instruction::SetLT)       // A < MIN -> FALSE