diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2006-11-28 20:23:51 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2006-11-28 20:23:51 +0000 |
commit | d4d9ab80b7b23c2f73192319e5582fb6802f5f18 (patch) | |
tree | b6dfa7d9d0659295954cfb2b757084fc606db895 /lib/Transforms | |
parent | ead1b801e26dbb46c8484787ba16ed5a2bea13fe (diff) |
Undo the last patch until 253.perlbmk passes with these changes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31977 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 49 |
1 files changed, 46 insertions, 3 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 532f112ebc..223624049e 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -5739,6 +5739,13 @@ Instruction *InstCombiner::commonIntCastTransforms(CastInst &CI) { unsigned SrcBitSize = SrcTy->getPrimitiveSizeInBits(); unsigned DestBitSize = DestTy->getPrimitiveSizeInBits(); + // FIXME. We currently implement cast-to-bool as a setne %X, 0. This is + // because codegen cannot accurately perform a truncate to bool operation. + // Something goes wrong in promotion to a larger type. When CodeGen can + // handle a proper truncation to bool, this should be removed. + if (DestTy == Type::BoolTy) + return BinaryOperator::createSetNE(Src, Constant::getNullValue(SrcTy)); + // See if we can simplify any instructions used by the LHS whose sole // purpose is to compute bits we don't care about. uint64_t KnownZero = 0, KnownOne = 0; @@ -6014,11 +6021,35 @@ Instruction *InstCombiner::visitFPExt(CastInst &CI) { } Instruction *InstCombiner::visitFPToUI(CastInst &CI) { - return commonCastTransforms(CI); + if (Instruction *I = commonCastTransforms(CI)) + return I; + + // FIXME. We currently implement cast-to-bool as a setne %X, 0. This is + // because codegen cannot accurately perform a truncate to bool operation. + // Something goes wrong in promotion to a larger type. When CodeGen can + // handle a proper truncation to bool, this should be removed. + Value *Src = CI.getOperand(0); + const Type *SrcTy = Src->getType(); + const Type *DestTy = CI.getType(); + if (DestTy == Type::BoolTy) + return BinaryOperator::createSetNE(Src, Constant::getNullValue(SrcTy)); + return 0; } Instruction *InstCombiner::visitFPToSI(CastInst &CI) { - return commonCastTransforms(CI); + if (Instruction *I = commonCastTransforms(CI)) + return I; + + // FIXME. We currently implement cast-to-bool as a setne %X, 0. This is + // because codegen cannot accurately perform a truncate to bool operation. + // Something goes wrong in promotion to a larger type. When CodeGen can + // handle a proper truncation to bool, this should be removed. + Value *Src = CI.getOperand(0); + const Type *SrcTy = Src->getType(); + const Type *DestTy = CI.getType(); + if (DestTy == Type::BoolTy) + return BinaryOperator::createSetNE(Src, Constant::getNullValue(SrcTy)); + return 0; } Instruction *InstCombiner::visitUIToFP(CastInst &CI) { @@ -6030,7 +6061,19 @@ Instruction *InstCombiner::visitSIToFP(CastInst &CI) { } Instruction *InstCombiner::visitPtrToInt(CastInst &CI) { - return commonCastTransforms(CI); + if (Instruction *I = commonCastTransforms(CI)) + return I; + + // FIXME. We currently implement cast-to-bool as a setne %X, 0. This is + // because codegen cannot accurately perform a truncate to bool operation. + // Something goes wrong in promotion to a larger type. When CodeGen can + // handle a proper truncation to bool, this should be removed. + Value *Src = CI.getOperand(0); + const Type *SrcTy = Src->getType(); + const Type *DestTy = CI.getType(); + if (DestTy == Type::BoolTy) + return BinaryOperator::createSetNE(Src, Constant::getNullValue(SrcTy)); + return 0; } Instruction *InstCombiner::visitIntToPtr(CastInst &CI) { |