diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2006-11-27 18:51:06 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2006-11-27 18:51:06 +0000 |
commit | 16eaffe595059abc6b1238c3b837c65bbacb973f (patch) | |
tree | 3bc97fc844ef6654702a4d35563c9c5f4f9e22df /llvm/lib/Target/CBackend | |
parent | f790e9de2c67b363eb2d2c16e9514b38f1becba4 (diff) | |
download | bcm5719-llvm-16eaffe595059abc6b1238c3b837c65bbacb973f.tar.gz bcm5719-llvm-16eaffe595059abc6b1238c3b837c65bbacb973f.zip |
When truncating to bool, it is necessary to & with 1 for all casts that
can result in a bool. Previously PtrToInt, FPToUI and FPToSI were missing
this operation.
llvm-svn: 31938
Diffstat (limited to 'llvm/lib/Target/CBackend')
-rw-r--r-- | llvm/lib/Target/CBackend/Writer.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/llvm/lib/Target/CBackend/Writer.cpp b/llvm/lib/Target/CBackend/Writer.cpp index bcc5fbf60ae..59ccf0079bd 100644 --- a/llvm/lib/Target/CBackend/Writer.cpp +++ b/llvm/lib/Target/CBackend/Writer.cpp @@ -626,8 +626,11 @@ void CWriter::printConstant(Constant *CPV) { Out << "0-"; } printConstant(CE->getOperand(0)); - if (CE->getOpcode() == Instruction::Trunc && - CE->getType() == Type::BoolTy) { + if (CE->getType() == Type::BoolTy && + (CE->getOpcode() == Instruction::Trunc || + CE->getOpcode() == Instruction::FPToUI || + CE->getOpcode() == Instruction::FPToSI || + CE->getOpcode() == Instruction::PtrToInt)) { // Make sure we really truncate to bool here by anding with 1 Out << "&1u"; } @@ -1960,7 +1963,11 @@ void CWriter::visitCastInst(CastInst &I) { Out << "0-"; } writeOperand(I.getOperand(0)); - if (I.getOpcode() == Instruction::Trunc && DstTy == Type::BoolTy) { + if (DstTy == Type::BoolTy && + (I.getOpcode() == Instruction::Trunc || + I.getOpcode() == Instruction::FPToUI || + I.getOpcode() == Instruction::FPToSI || + I.getOpcode() == Instruction::PtrToInt)) { // Make sure we really get a trunc to bool by anding the operand with 1 Out << "&1u"; } |