From: Chris Lattner Date: Tue, 2 Nov 2004 03:50:32 +0000 (+0000) Subject: * Rearrange code slightly X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d308f8a87fd32cd5b53386a664033e68c7c460b9;p=oota-llvm.git * Rearrange code slightly * Disable broken transforms for simplifying (setcc (cast X to larger), CI) where CC is not != or == git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17422 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index f8f0573395d..9274a4259cf 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -2024,29 +2024,38 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) { if (SrcTy == Type::BoolTy) SrcBits = 1; unsigned DestBits = LHSI->getType()->getPrimitiveSize()*8; if (LHSI->getType() == Type::BoolTy) DestBits = 1; - if (SrcBits < DestBits) { + if (SrcBits < DestBits && + // FIXME: Reenable the code below for < and >. However, we have + // to handle the cases when the source of the cast and the dest of + // the cast have different signs. e.g: + // (cast sbyte %X to uint) >u 255U -> X getType()) != CI) { - Constant *Min = ConstantIntegral::getMinValue(SrcTy); - Constant *Max = ConstantIntegral::getMaxValue(SrcTy); - Min = ConstantExpr::getCast(Min, LHSI->getType()); - Max = ConstantExpr::getCast(Max, LHSI->getType()); switch (I.getOpcode()) { default: assert(0 && "unknown integer comparison"); +#if 0 + case Instruction::SetLT: { + Constant *Max = ConstantIntegral::getMaxValue(SrcTy); + Max = ConstantExpr::getCast(Max, LHSI->getType()); + return ReplaceInstUsesWith(I, ConstantExpr::getSetLT(Max, CI)); + } + case Instruction::SetGT: { + Constant *Min = ConstantIntegral::getMinValue(SrcTy); + Min = ConstantExpr::getCast(Min, LHSI->getType()); + return ReplaceInstUsesWith(I, ConstantExpr::getSetGT(Min, CI)); + } +#endif case Instruction::SetEQ: return ReplaceInstUsesWith(I, ConstantBool::False); case Instruction::SetNE: return ReplaceInstUsesWith(I, ConstantBool::True); - case Instruction::SetLT: - return ReplaceInstUsesWith(I, ConstantExpr::getSetLT(Max, CI)); - case Instruction::SetGT: - return ReplaceInstUsesWith(I, ConstantExpr::getSetGT(Min, CI)); } } - return new SetCondInst(I.getOpcode(), LHSI->getOperand(0), - ConstantExpr::getCast(CI, SrcTy)); + return new SetCondInst(I.getOpcode(), LHSI->getOperand(0), NewCst); } } break;