summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar
diff options
context:
space:
mode:
authorAnton Korobeynikov <asl@math.spbu.ru>2008-02-20 11:26:25 +0000
committerAnton Korobeynikov <asl@math.spbu.ru>2008-02-20 11:26:25 +0000
commit1bfd121321fbe487e3fd343804b77412d3f33fe8 (patch)
tree9b1bb483cccafe0349272ce86ae2aca892edcc33 /llvm/lib/Transforms/Scalar
parent852e2149939e2d13685647dc64a1d2b2c1bf9494 (diff)
downloadbcm5719-llvm-1bfd121321fbe487e3fd343804b77412d3f33fe8.tar.gz
bcm5719-llvm-1bfd121321fbe487e3fd343804b77412d3f33fe8.zip
Make Transforms to be 4.3 warnings-clean
llvm-svn: 47371
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
-rw-r--r--llvm/lib/Transforms/Scalar/GVN.cpp12
-rw-r--r--llvm/lib/Transforms/Scalar/GVNPRE.cpp12
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp37
-rw-r--r--llvm/lib/Transforms/Scalar/SCCP.cpp4
-rw-r--r--llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp4
5 files changed, 40 insertions, 29 deletions
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp
index 481956f6b4c..5ad9cbbb2f1 100644
--- a/llvm/lib/Transforms/Scalar/GVN.cpp
+++ b/llvm/lib/Transforms/Scalar/GVN.cpp
@@ -174,17 +174,17 @@ template <> struct DenseMapInfo<Expression> {
hash = e.secondVN + hash * 37;
hash = e.thirdVN + hash * 37;
- hash = (unsigned)((uintptr_t)e.type >> 4) ^
- (unsigned)((uintptr_t)e.type >> 9) +
- hash * 37;
+ hash = ((unsigned)((uintptr_t)e.type >> 4) ^
+ (unsigned)((uintptr_t)e.type >> 9)) +
+ hash * 37;
for (SmallVector<uint32_t, 4>::const_iterator I = e.varargs.begin(),
E = e.varargs.end(); I != E; ++I)
hash = *I + hash * 37;
- hash = (unsigned)((uintptr_t)e.function >> 4) ^
- (unsigned)((uintptr_t)e.function >> 9) +
- hash * 37;
+ hash = ((unsigned)((uintptr_t)e.function >> 4) ^
+ (unsigned)((uintptr_t)e.function >> 9)) +
+ hash * 37;
return hash;
}
diff --git a/llvm/lib/Transforms/Scalar/GVNPRE.cpp b/llvm/lib/Transforms/Scalar/GVNPRE.cpp
index a2a221a405b..7d38dc75a1e 100644
--- a/llvm/lib/Transforms/Scalar/GVNPRE.cpp
+++ b/llvm/lib/Transforms/Scalar/GVNPRE.cpp
@@ -171,9 +171,9 @@ template <> struct DenseMapInfo<Expression> {
hash = e.secondVN + hash * 37;
hash = e.thirdVN + hash * 37;
- hash = (unsigned)((uintptr_t)e.type >> 4) ^
- (unsigned)((uintptr_t)e.type >> 9) +
- hash * 37;
+ hash = ((unsigned)((uintptr_t)e.type >> 4) ^
+ (unsigned)((uintptr_t)e.type >> 9)) +
+ hash * 37;
for (SmallVector<uint32_t, 4>::const_iterator I = e.varargs.begin(),
E = e.varargs.end(); I != E; ++I)
@@ -1599,7 +1599,7 @@ void GVNPRE::insertion_pre(Value* e, BasicBlock* BB,
isa<ShuffleVectorInst>(U) ||
isa<ExtractElementInst>(U) ||
isa<InsertElementInst>(U) ||
- isa<SelectInst>(U))
+ isa<SelectInst>(U)) {
if (isa<BinaryOperator>(U->getOperand(1)) ||
isa<CmpInst>(U->getOperand(1)) ||
isa<ShuffleVectorInst>(U->getOperand(1)) ||
@@ -1612,12 +1612,13 @@ void GVNPRE::insertion_pre(Value* e, BasicBlock* BB,
} else {
s2 = U->getOperand(1);
}
+ }
// Ternary Operators
Value* s3 = 0;
if (isa<ShuffleVectorInst>(U) ||
isa<InsertElementInst>(U) ||
- isa<SelectInst>(U))
+ isa<SelectInst>(U)) {
if (isa<BinaryOperator>(U->getOperand(2)) ||
isa<CmpInst>(U->getOperand(2)) ||
isa<ShuffleVectorInst>(U->getOperand(2)) ||
@@ -1630,6 +1631,7 @@ void GVNPRE::insertion_pre(Value* e, BasicBlock* BB,
} else {
s3 = U->getOperand(2);
}
+ }
// Vararg operators
SmallVector<Value*, 4> sVarargs;
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index ba9ce568f33..12008956153 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -2303,7 +2303,7 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
// -(X >>u 31) -> (X >>s 31)
// -(X >>s 31) -> (X >>u 31)
if (C->isZero()) {
- if (BinaryOperator *SI = dyn_cast<BinaryOperator>(Op1))
+ if (BinaryOperator *SI = dyn_cast<BinaryOperator>(Op1)) {
if (SI->getOpcode() == Instruction::LShr) {
if (ConstantInt *CU = dyn_cast<ConstantInt>(SI->getOperand(1))) {
// Check to see if we are shifting out everything but the sign bit.
@@ -2325,7 +2325,8 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
SI->getOperand(0), CU, SI->getName());
}
}
- }
+ }
+ }
}
// Try to fold constant sub into select arguments.
@@ -2408,7 +2409,7 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
}
if (!Op0->getType()->isFPOrFPVector())
- if (BinaryOperator *Op0I = dyn_cast<BinaryOperator>(Op0))
+ if (BinaryOperator *Op0I = dyn_cast<BinaryOperator>(Op0)) {
if (Op0I->getOpcode() == Instruction::Add) {
if (Op0I->getOperand(0) == Op1) // (Y+X)-Y == X
return ReplaceInstUsesWith(I, Op0I->getOperand(1));
@@ -2418,6 +2419,7 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
if (Op0I->getOperand(0) == Op1) // (X-Y)-X == -Y
return BinaryOperator::createNeg(Op0I->getOperand(1), I.getName());
}
+ }
ConstantInt *C1;
if (Value *X = dyn_castFoldableMul(Op0, C1)) {
@@ -3116,8 +3118,8 @@ struct FoldICmpLogical {
bool shouldApply(Value *V) const {
if (ICmpInst *ICI = dyn_cast<ICmpInst>(V))
if (PredicatesFoldable(pred, ICI->getPredicate()))
- return (ICI->getOperand(0) == LHS && ICI->getOperand(1) == RHS ||
- ICI->getOperand(0) == RHS && ICI->getOperand(1) == LHS);
+ return ((ICI->getOperand(0) == LHS && ICI->getOperand(1) == RHS) ||
+ (ICI->getOperand(0) == RHS && ICI->getOperand(1) == LHS));
return false;
}
Instruction *apply(Instruction &Log) const {
@@ -3499,7 +3501,7 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) {
if (Instruction *CastOp = dyn_cast<Instruction>(CI->getOperand(0))) {
if ((isa<TruncInst>(CI) || isa<BitCastInst>(CI)) &&
CastOp->getNumOperands() == 2)
- if (ConstantInt *AndCI = dyn_cast<ConstantInt>(CastOp->getOperand(1)))
+ if (ConstantInt *AndCI = dyn_cast<ConstantInt>(CastOp->getOperand(1))) {
if (CastOp->getOpcode() == Instruction::And) {
// Change: and (cast (and X, C1) to T), C2
// into : and (cast X to T), trunc_or_bitcast(C1)&C2
@@ -3520,6 +3522,7 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) {
if (ConstantExpr::getAnd(C3, AndRHS) == AndRHS) // trunc(C1)&C2
return ReplaceInstUsesWith(I, AndRHS);
}
+ }
}
}
@@ -4384,7 +4387,7 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
return BinaryOperator::createAdd(Op0I->getOperand(1), ConstantRHS);
}
- if (ConstantInt *Op0CI = dyn_cast<ConstantInt>(Op0I->getOperand(1)))
+ if (ConstantInt *Op0CI = dyn_cast<ConstantInt>(Op0I->getOperand(1))) {
if (Op0I->getOpcode() == Instruction::Add) {
// ~(X-c) --> (-c-1)-X
if (RHS->isAllOnesValue()) {
@@ -4414,6 +4417,7 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
return &I;
}
}
+ }
}
// Try to fold constant and into select arguments.
@@ -5184,13 +5188,14 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
Op1 = CI2->getOperand(0);
// If Op1 is a constant, we can fold the cast into the constant.
- if (Op0->getType() != Op1->getType())
+ if (Op0->getType() != Op1->getType()) {
if (Constant *Op1C = dyn_cast<Constant>(Op1)) {
Op1 = ConstantExpr::getBitCast(Op1C, Op0->getType());
} else {
// Otherwise, cast the RHS right before the icmp
Op1 = InsertBitCastBefore(Op1, Op0->getType(), I);
}
+ }
return new ICmpInst(I.getPredicate(), Op0, Op1);
}
}
@@ -5437,8 +5442,8 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
if (ConstantInt *XorCST = dyn_cast<ConstantInt>(LHSI->getOperand(1))) {
// If this is a comparison that tests the signbit (X < 0) or (x > -1),
// fold the xor.
- if (ICI.getPredicate() == ICmpInst::ICMP_SLT && RHSV == 0 ||
- ICI.getPredicate() == ICmpInst::ICMP_SGT && RHSV.isAllOnesValue()) {
+ if ((ICI.getPredicate() == ICmpInst::ICMP_SLT && RHSV == 0) ||
+ (ICI.getPredicate() == ICmpInst::ICMP_SGT && RHSV.isAllOnesValue())) {
Value *CompareVal = LHSI->getOperand(0);
// If the sign bit of the XorCST is not set, there is no change to
@@ -8492,7 +8497,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
Args.push_back(Constant::getNullValue(FT->getParamType(i)));
// If we are removing arguments to the function, emit an obnoxious warning...
- if (FT->getNumParams() < NumActualArgs)
+ if (FT->getNumParams() < NumActualArgs) {
if (!FT->isVarArg()) {
cerr << "WARNING: While resolving call to function '"
<< Callee->getName() << "' arguments were dropped!\n";
@@ -8519,6 +8524,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
attrVec.push_back(ParamAttrsWithIndex::get(i + 1, PAttrs));
}
}
+ }
if (FT->getReturnType() == Type::VoidTy)
Caller->setName(""); // Void type should not have a name.
@@ -9131,7 +9137,7 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
// insert it. This explicit cast can make subsequent optimizations more
// obvious.
Value *Op = GEP.getOperand(i);
- if (TD->getTypeSizeInBits(Op->getType()) > TD->getPointerSizeInBits())
+ if (TD->getTypeSizeInBits(Op->getType()) > TD->getPointerSizeInBits()) {
if (Constant *C = dyn_cast<Constant>(Op)) {
GEP.setOperand(i, ConstantExpr::getTrunc(C, TD->getIntPtrType()));
MadeChange = true;
@@ -9141,6 +9147,7 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
GEP.setOperand(i, Op);
MadeChange = true;
}
+ }
}
}
if (MadeChange) return &GEP;
@@ -9383,7 +9390,7 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
Instruction *InstCombiner::visitAllocationInst(AllocationInst &AI) {
// Convert: malloc Ty, C - where C is a constant != 1 into: malloc [C x Ty], 1
- if (AI.isArrayAllocation()) // Check C != 1
+ if (AI.isArrayAllocation()) { // Check C != 1
if (const ConstantInt *C = dyn_cast<ConstantInt>(AI.getArraySize())) {
const Type *NewTy =
ArrayType::get(AI.getAllocatedType(), C->getZExtValue());
@@ -9421,6 +9428,7 @@ Instruction *InstCombiner::visitAllocationInst(AllocationInst &AI) {
} else if (isa<UndefValue>(AI.getArraySize())) {
return ReplaceInstUsesWith(AI, Constant::getNullValue(AI.getType()));
}
+ }
// If alloca'ing a zero byte object, replace the alloca with a null pointer.
// Note that we only do this for alloca's, because malloc should allocate and
@@ -9669,7 +9677,7 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) {
return ReplaceInstUsesWith(LI, GV->getInitializer());
// Instcombine load (constantexpr_GEP global, 0, ...) into the value loaded.
- if (ConstantExpr *CE = dyn_cast<ConstantExpr>(Op))
+ if (ConstantExpr *CE = dyn_cast<ConstantExpr>(Op)) {
if (CE->getOpcode() == Instruction::GetElementPtr) {
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(CE->getOperand(0)))
if (GV->isConstant() && !GV->isDeclaration())
@@ -9690,6 +9698,7 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) {
if (Instruction *Res = InstCombineLoadCast(*this, LI, TD))
return Res;
}
+ }
}
// If this load comes from anywhere in a constant global, and if the global
diff --git a/llvm/lib/Transforms/Scalar/SCCP.cpp b/llvm/lib/Transforms/Scalar/SCCP.cpp
index 07e70099769..561cdb1fbb4 100644
--- a/llvm/lib/Transforms/Scalar/SCCP.cpp
+++ b/llvm/lib/Transforms/Scalar/SCCP.cpp
@@ -1608,8 +1608,8 @@ bool IPSCCP::runOnModule(Module &M) {
Instruction *Inst = BI++;
if (Inst->getType() != Type::VoidTy) {
LatticeVal &IV = Values[Inst];
- if (IV.isConstant() || IV.isUndefined() &&
- !isa<TerminatorInst>(Inst)) {
+ if (IV.isConstant() ||
+ (IV.isUndefined() && !isa<TerminatorInst>(Inst))) {
Constant *Const = IV.isConstant()
? IV.getConstant() : UndefValue::get(Inst->getType());
DOUT << " Constant: " << *Const << " = " << *Inst;
diff --git a/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp b/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
index 5849254374d..0623abe5dd1 100644
--- a/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
@@ -279,8 +279,8 @@ Value *TailCallElim::CanTransformAccumulatorRecursion(Instruction *I,
"Associative operations should have 2 args!");
// Exactly one operand should be the result of the call instruction...
- if (I->getOperand(0) == CI && I->getOperand(1) == CI ||
- I->getOperand(0) != CI && I->getOperand(1) != CI)
+ if ((I->getOperand(0) == CI && I->getOperand(1) == CI) ||
+ (I->getOperand(0) != CI && I->getOperand(1) != CI))
return 0;
// The only user of this instruction we allow is a single return instruction.
OpenPOWER on IntegriCloud