Implement instcombine/cast.ll:test16:

Canonicalize cast X to bool into a setne instruction

llvm-svn: 13736
This commit is contained in:
Chris Lattner 2004-05-25 04:29:21 +00:00
parent 608c18f20c
commit 03841659a4
1 changed files with 5 additions and 0 deletions

View File

@ -1996,6 +1996,11 @@ Instruction *InstCombiner::visitCastInst(CastInst &CI) {
}
}
// If this is a cast to bool, turn it into the appropriate setne instruction.
if (CI.getType() == Type::BoolTy)
return BinaryOperator::create(Instruction::SetNE, CI.getOperand(0),
Constant::getNullValue(CI.getOperand(0)->getType()));
// If casting the result of a getelementptr instruction with no offset, turn
// this into a cast of the original pointer!
//