From: Chris Lattner Date: Sun, 1 Jun 2003 03:35:25 +0000 (+0000) Subject: Implement xform: (X != 0) -> (bool)X X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=074d84c746f6e4592be3e87ed56ea6b9059d0e82;p=oota-llvm.git Implement xform: (X != 0) -> (bool)X git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6506 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index f78f6750ef6..21c58b696e0 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -682,6 +682,9 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) { // integers at the end of their ranges... // if (ConstantInt *CI = dyn_cast(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