reduce indentation

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92766 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2010-01-05 20:56:24 +00:00
parent 6ca835dedf
commit 3168c7dd25

View File

@ -35,20 +35,23 @@ static Constant *SubOne(ConstantInt *C) {
// Otherwise, return null. // Otherwise, return null.
// //
static inline Value *dyn_castFoldableMul(Value *V, ConstantInt *&CST) { static inline Value *dyn_castFoldableMul(Value *V, ConstantInt *&CST) {
if (V->hasOneUse() && V->getType()->isInteger()) if (!V->hasOneUse() || !V->getType()->isInteger())
if (Instruction *I = dyn_cast<Instruction>(V)) { return 0;
if (I->getOpcode() == Instruction::Mul)
if ((CST = dyn_cast<ConstantInt>(I->getOperand(1)))) Instruction *I = dyn_cast<Instruction>(V);
return I->getOperand(0); if (I == 0) return 0;
if (I->getOpcode() == Instruction::Shl)
if ((CST = dyn_cast<ConstantInt>(I->getOperand(1)))) { if (I->getOpcode() == Instruction::Mul)
// The multiplier is really 1 << CST. if ((CST = dyn_cast<ConstantInt>(I->getOperand(1))))
uint32_t BitWidth = cast<IntegerType>(V->getType())->getBitWidth(); return I->getOperand(0);
uint32_t CSTVal = CST->getLimitedValue(BitWidth); if (I->getOpcode() == Instruction::Shl)
CST = ConstantInt::get(V->getType()->getContext(), if ((CST = dyn_cast<ConstantInt>(I->getOperand(1)))) {
APInt(BitWidth, 1).shl(CSTVal)); // The multiplier is really 1 << CST.
return I->getOperand(0); uint32_t BitWidth = cast<IntegerType>(V->getType())->getBitWidth();
} uint32_t CSTVal = CST->getLimitedValue(BitWidth);
CST = ConstantInt::get(V->getType()->getContext(),
APInt(BitWidth, 1).shl(CSTVal));
return I->getOperand(0);
} }
return 0; return 0;
} }
@ -345,7 +348,7 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
RHSConv->getOperand(0))) { RHSConv->getOperand(0))) {
// Insert the new integer add. // Insert the new integer add.
Value *NewAdd = Builder->CreateNSWAdd(LHSConv->getOperand(0), Value *NewAdd = Builder->CreateNSWAdd(LHSConv->getOperand(0),
RHSConv->getOperand(0), "addconv"); RHSConv->getOperand(0), "addconv");
return new SExtInst(NewAdd, I.getType()); return new SExtInst(NewAdd, I.getType());
} }
} }