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 | a710ddc9c4146764d7bf802ae784d86def71175d (patch) | |
tree | f6070df71498537692eaa806bc91d9e53a9b0d23 /lib/Transforms | |
parent | 2e13cea8964746fdbac8fb4a722d98927fb16cc4 (diff) |
Implement instcombine/cast.ll:test16:
Canonicalize cast X to bool into a setne instruction
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13736 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 67b99c56e7..d31e7e8333 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/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! // |