diff options
author | Chris Lattner <sabre@nondot.org> | 2004-05-25 04:29:21 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-05-25 04:29:21 +0000 |
commit | 03841659a4d3227b2606480c66a0d790e54dbb5d (patch) | |
tree | 4c110af6bf3bd6e7c54ab0361dacac2de365fcb1 /llvm/lib/Transforms | |
parent | 608c18f20c5b52eb35bda5611207bb85123c1727 (diff) | |
download | bcm5719-llvm-03841659a4d3227b2606480c66a0d790e54dbb5d.tar.gz bcm5719-llvm-03841659a4d3227b2606480c66a0d790e54dbb5d.zip |
Implement instcombine/cast.ll:test16:
Canonicalize cast X to bool into a setne instruction
llvm-svn: 13736
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index 67b99c56e7e..d31e7e83332 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp @@ -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! // |