Implement xform: (X != 0) -> (bool)X

llvm-svn: 6506
This commit is contained in:
Chris Lattner 2003-06-01 03:35:25 +00:00
parent ef33748248
commit 791ac1a4c8
1 changed files with 3 additions and 0 deletions

View 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