From 40c2cf4afc13947b3fe301df17266d4a0bcf10cb Mon Sep 17 00:00:00 2001 From: Akira Hatanaka Date: Thu, 16 Oct 2014 01:17:02 +0000 Subject: Revert r219832. llvm-svn: 219884 --- .../InstCombine/InstructionCombining.cpp | 31 ---------------------- 1 file changed, 31 deletions(-) (limited to 'llvm/lib') diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp index e158c11b1fd..ac0c01e3c7b 100644 --- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -2075,37 +2075,6 @@ Instruction *InstCombiner::visitBranchInst(BranchInst &BI) { Instruction *InstCombiner::visitSwitchInst(SwitchInst &SI) { Value *Cond = SI.getCondition(); - unsigned BitWidth = cast(Cond->getType())->getBitWidth(); - APInt KnownZero(BitWidth, 0), KnownOne(BitWidth, 0); - computeKnownBits(Cond, KnownZero, KnownOne); - unsigned LeadingKnownZeros = KnownZero.countLeadingOnes(); - unsigned LeadingKnownOnes = KnownOne.countLeadingOnes(); - - // Compute the number of leading bits we can ignore. - for (auto &C : SI.cases()) { - LeadingKnownZeros = std::min( - LeadingKnownZeros, C.getCaseValue()->getValue().countLeadingZeros()); - LeadingKnownOnes = std::min( - LeadingKnownOnes, C.getCaseValue()->getValue().countLeadingOnes()); - } - - unsigned NewWidth = BitWidth - std::max(LeadingKnownZeros, LeadingKnownOnes); - - // Truncate the condition operand if the new type is equal to or larger than - // the largest legal integer type. We need to be conservative here since - // x86 generates redundant zero-extenstion instructions if the operand is - // truncated to i8 or i16. - if (BitWidth > NewWidth && NewWidth >= DL->getLargestLegalIntTypeSize()) { - IntegerType *Ty = IntegerType::get(SI.getContext(), NewWidth); - Builder->SetInsertPoint(&SI); - Value *NewCond = Builder->CreateTrunc(SI.getCondition(), Ty, "trunc"); - SI.setCondition(NewCond); - - for (auto &C : SI.cases()) - static_cast(&C)->setValue( - ConstantInt::get(Ty, C.getCaseValue()->getValue().getZExtValue())); - } - if (Instruction *I = dyn_cast(Cond)) { if (I->getOpcode() == Instruction::Add) if (ConstantInt *AddRHS = dyn_cast(I->getOperand(1))) { -- cgit v1.2.3