diff options
author | Chris Lattner <sabre@nondot.org> | 2010-01-05 20:56:24 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-01-05 20:56:24 +0000 |
commit | f2d78a74f5c923256d257b89bf957d4428d2f972 (patch) | |
tree | 6b8a6f4d565109b946ba1326e6f8b00f670067e7 /lib | |
parent | c5cbb461133c2b6aaf6952f44ee4f4ba0de57a35 (diff) | |
download | external_llvm-f2d78a74f5c923256d257b89bf957d4428d2f972.zip external_llvm-f2d78a74f5c923256d257b89bf957d4428d2f972.tar.gz external_llvm-f2d78a74f5c923256d257b89bf957d4428d2f972.tar.bz2 |
reduce indentation
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92766 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/InstCombine/InstCombineAddSub.cpp | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/lib/Transforms/InstCombine/InstCombineAddSub.cpp index 9332257..c8556ea 100644 --- a/lib/Transforms/InstCombine/InstCombineAddSub.cpp +++ b/lib/Transforms/InstCombine/InstCombineAddSub.cpp @@ -35,20 +35,23 @@ static Constant *SubOne(ConstantInt *C) { // Otherwise, return null. // static inline Value *dyn_castFoldableMul(Value *V, ConstantInt *&CST) { - if (V->hasOneUse() && V->getType()->isInteger()) - if (Instruction *I = dyn_cast<Instruction>(V)) { - if (I->getOpcode() == Instruction::Mul) - if ((CST = dyn_cast<ConstantInt>(I->getOperand(1)))) - return I->getOperand(0); - if (I->getOpcode() == Instruction::Shl) - if ((CST = dyn_cast<ConstantInt>(I->getOperand(1)))) { - // The multiplier is really 1 << CST. - 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); - } + if (!V->hasOneUse() || !V->getType()->isInteger()) + return 0; + + Instruction *I = dyn_cast<Instruction>(V); + if (I == 0) return 0; + + if (I->getOpcode() == Instruction::Mul) + if ((CST = dyn_cast<ConstantInt>(I->getOperand(1)))) + return I->getOperand(0); + if (I->getOpcode() == Instruction::Shl) + if ((CST = dyn_cast<ConstantInt>(I->getOperand(1)))) { + // The multiplier is really 1 << CST. + 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; } @@ -345,7 +348,7 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) { RHSConv->getOperand(0))) { // Insert the new integer add. Value *NewAdd = Builder->CreateNSWAdd(LHSConv->getOperand(0), - RHSConv->getOperand(0), "addconv"); + RHSConv->getOperand(0), "addconv"); return new SExtInst(NewAdd, I.getType()); } } |