summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-01-05 20:56:24 +0000
committerChris Lattner <sabre@nondot.org>2010-01-05 20:56:24 +0000
commitdec6847bf6fde0dfecd6f1c0e9a47f74f4219a0f (patch)
tree5aa068c20e3ae72447f6e08eadef2f049f5c0aac /llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
parent902292d7ac1c59dc9fd3b4fc3823be0ed77febf9 (diff)
downloadbcm5719-llvm-dec6847bf6fde0dfecd6f1c0e9a47f74f4219a0f.tar.gz
bcm5719-llvm-dec6847bf6fde0dfecd6f1c0e9a47f74f4219a0f.zip
reduce indentation
llvm-svn: 92766
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp33
1 files changed, 18 insertions, 15 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
index 9332257acec..c8556ea01d8 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
+++ b/llvm/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());
}
}
OpenPOWER on IntegriCloud