// If this is a direct store to the global (i.e., the global is a scalar
// value, not an aggregate), keep more specific information about
// stores.
// If this is a direct store to the global (i.e., the global is a scalar
// value, not an aggregate), keep more specific information about
// stores.
- if (GS.StoredType != GlobalStatus::isStored)
+ if (GS.StoredType != GlobalStatus::isStored) {
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(SI->getOperand(1))){
Value *StoredVal = SI->getOperand(0);
if (StoredVal == GV->getInitializer()) {
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(SI->getOperand(1))){
Value *StoredVal = SI->getOperand(0);
if (StoredVal == GV->getInitializer()) {
} else {
GS.StoredType = GlobalStatus::isStored;
}
} else {
GS.StoredType = GlobalStatus::isStored;
}
} else if (isa<GetElementPtrInst>(I)) {
if (AnalyzeGlobal(I, GS, PHIUsers)) return true;
} else if (isa<SelectInst>(I)) {
} else if (isa<GetElementPtrInst>(I)) {
if (AnalyzeGlobal(I, GS, PHIUsers)) return true;
} else if (isa<SelectInst>(I)) {
Value *NewPtr = NewGlobals[Val];
// Form a shorter GEP if needed.
Value *NewPtr = NewGlobals[Val];
// Form a shorter GEP if needed.
- if (GEP->getNumOperands() > 3)
+ if (GEP->getNumOperands() > 3) {
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(GEP)) {
SmallVector<Constant*, 8> Idxs;
Idxs.push_back(NullInt);
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(GEP)) {
SmallVector<Constant*, 8> Idxs;
Idxs.push_back(NullInt);
NewPtr = new GetElementPtrInst(NewPtr, Idxs.begin(), Idxs.end(),
GEPI->getName()+"."+utostr(Val), GEPI);
}
NewPtr = new GetElementPtrInst(NewPtr, Idxs.begin(), Idxs.end(),
GEPI->getName()+"."+utostr(Val), GEPI);
}
GEP->replaceAllUsesWith(NewPtr);
if (GetElementPtrInst *GEPI = dyn_cast<GetElementPtrInst>(GEP))
GEP->replaceAllUsesWith(NewPtr);
if (GetElementPtrInst *GEPI = dyn_cast<GetElementPtrInst>(GEP))
// Check to see if this function returns a constant.
Value *RetVal = 0;
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
// Check to see if this function returns a constant.
Value *RetVal = 0;
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
- if (ReturnInst *RI = dyn_cast<ReturnInst>(BB->getTerminator()))
+ if (ReturnInst *RI = dyn_cast<ReturnInst>(BB->getTerminator())) {
if (isa<UndefValue>(RI->getOperand(0))) {
// Ignore.
} else if (Constant *C = dyn_cast<Constant>(RI->getOperand(0))) {
if (isa<UndefValue>(RI->getOperand(0))) {
// Ignore.
} else if (Constant *C = dyn_cast<Constant>(RI->getOperand(0))) {
} else {
return false; // Does not return a constant.
}
} else {
return false; // Does not return a constant.
}
if (RetVal == 0) RetVal = UndefValue::get(F.getReturnType());
if (RetVal == 0) RetVal = UndefValue::get(F.getReturnType());
hash = e.secondVN + hash * 37;
hash = e.thirdVN + hash * 37;
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;
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;
hash = e.secondVN + hash * 37;
hash = e.thirdVN + hash * 37;
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)
for (SmallVector<uint32_t, 4>::const_iterator I = e.varargs.begin(),
E = e.varargs.end(); I != E; ++I)
isa<ShuffleVectorInst>(U) ||
isa<ExtractElementInst>(U) ||
isa<InsertElementInst>(U) ||
isa<ShuffleVectorInst>(U) ||
isa<ExtractElementInst>(U) ||
isa<InsertElementInst>(U) ||
if (isa<BinaryOperator>(U->getOperand(1)) ||
isa<CmpInst>(U->getOperand(1)) ||
isa<ShuffleVectorInst>(U->getOperand(1)) ||
if (isa<BinaryOperator>(U->getOperand(1)) ||
isa<CmpInst>(U->getOperand(1)) ||
isa<ShuffleVectorInst>(U->getOperand(1)) ||
} else {
s2 = U->getOperand(1);
}
} else {
s2 = U->getOperand(1);
}
// Ternary Operators
Value* s3 = 0;
if (isa<ShuffleVectorInst>(U) ||
isa<InsertElementInst>(U) ||
// Ternary Operators
Value* s3 = 0;
if (isa<ShuffleVectorInst>(U) ||
isa<InsertElementInst>(U) ||
if (isa<BinaryOperator>(U->getOperand(2)) ||
isa<CmpInst>(U->getOperand(2)) ||
isa<ShuffleVectorInst>(U->getOperand(2)) ||
if (isa<BinaryOperator>(U->getOperand(2)) ||
isa<CmpInst>(U->getOperand(2)) ||
isa<ShuffleVectorInst>(U->getOperand(2)) ||
} else {
s3 = U->getOperand(2);
}
} else {
s3 = U->getOperand(2);
}
// Vararg operators
SmallVector<Value*, 4> sVarargs;
// Vararg operators
SmallVector<Value*, 4> sVarargs;
// -(X >>u 31) -> (X >>s 31)
// -(X >>s 31) -> (X >>u 31)
if (C->isZero()) {
// -(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.
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.
SI->getOperand(0), CU, SI->getName());
}
}
SI->getOperand(0), CU, SI->getName());
}
}
}
// Try to fold constant sub into select arguments.
}
// Try to fold constant sub into select arguments.
}
if (!Op0->getType()->isFPOrFPVector())
}
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));
if (Op0I->getOpcode() == Instruction::Add) {
if (Op0I->getOperand(0) == Op1) // (Y+X)-Y == X
return ReplaceInstUsesWith(I, Op0I->getOperand(1));
if (Op0I->getOperand(0) == Op1) // (X-Y)-X == -Y
return BinaryOperator::createNeg(Op0I->getOperand(1), I.getName());
}
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)) {
ConstantInt *C1;
if (Value *X = dyn_castFoldableMul(Op0, C1)) {
bool shouldApply(Value *V) const {
if (ICmpInst *ICI = dyn_cast<ICmpInst>(V))
if (PredicatesFoldable(pred, ICI->getPredicate()))
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 {
return false;
}
Instruction *apply(Instruction &Log) const {
if (Instruction *CastOp = dyn_cast<Instruction>(CI->getOperand(0))) {
if ((isa<TruncInst>(CI) || isa<BitCastInst>(CI)) &&
CastOp->getNumOperands() == 2)
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
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
if (ConstantExpr::getAnd(C3, AndRHS) == AndRHS) // trunc(C1)&C2
return ReplaceInstUsesWith(I, AndRHS);
}
if (ConstantExpr::getAnd(C3, AndRHS) == AndRHS) // trunc(C1)&C2
return ReplaceInstUsesWith(I, AndRHS);
}
return BinaryOperator::createAdd(Op0I->getOperand(1), ConstantRHS);
}
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()) {
if (Op0I->getOpcode() == Instruction::Add) {
// ~(X-c) --> (-c-1)-X
if (RHS->isAllOnesValue()) {
}
// Try to fold constant and into select arguments.
}
// Try to fold constant and into select arguments.
Op1 = CI2->getOperand(0);
// If Op1 is a constant, we can fold the cast into the constant.
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);
}
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);
}
}
return new ICmpInst(I.getPredicate(), Op0, Op1);
}
}
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 (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
Value *CompareVal = LHSI->getOperand(0);
// If the sign bit of the XorCST is not set, there is no change to
Args.push_back(Constant::getNullValue(FT->getParamType(i)));
// If we are removing arguments to the function, emit an obnoxious warning...
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";
if (!FT->isVarArg()) {
cerr << "WARNING: While resolving call to function '"
<< Callee->getName() << "' arguments were dropped!\n";
attrVec.push_back(ParamAttrsWithIndex::get(i + 1, PAttrs));
}
}
attrVec.push_back(ParamAttrsWithIndex::get(i + 1, PAttrs));
}
}
if (FT->getReturnType() == Type::VoidTy)
Caller->setName(""); // Void type should not have a name.
if (FT->getReturnType() == Type::VoidTy)
Caller->setName(""); // Void type should not have a name.
// insert it. This explicit cast can make subsequent optimizations more
// obvious.
Value *Op = GEP.getOperand(i);
// 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;
if (Constant *C = dyn_cast<Constant>(Op)) {
GEP.setOperand(i, ConstantExpr::getTrunc(C, TD->getIntPtrType()));
MadeChange = true;
GEP.setOperand(i, Op);
MadeChange = true;
}
GEP.setOperand(i, Op);
MadeChange = true;
}
}
}
if (MadeChange) return &GEP;
}
}
if (MadeChange) return &GEP;
Instruction *InstCombiner::visitAllocationInst(AllocationInst &AI) {
// Convert: malloc Ty, C - where C is a constant != 1 into: malloc [C x Ty], 1
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());
if (const ConstantInt *C = dyn_cast<ConstantInt>(AI.getArraySize())) {
const Type *NewTy =
ArrayType::get(AI.getAllocatedType(), C->getZExtValue());
} else if (isa<UndefValue>(AI.getArraySize())) {
return ReplaceInstUsesWith(AI, Constant::getNullValue(AI.getType()));
}
} 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
// 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
return ReplaceInstUsesWith(LI, GV->getInitializer());
// Instcombine load (constantexpr_GEP global, 0, ...) into the value loaded.
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())
if (CE->getOpcode() == Instruction::GetElementPtr) {
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(CE->getOperand(0)))
if (GV->isConstant() && !GV->isDeclaration())
if (Instruction *Res = InstCombineLoadCast(*this, LI, TD))
return Res;
}
if (Instruction *Res = InstCombineLoadCast(*this, LI, TD))
return Res;
}
}
// If this load comes from anywhere in a constant global, and if the global
}
// If this load comes from anywhere in a constant global, and if the global
Instruction *Inst = BI++;
if (Inst->getType() != Type::VoidTy) {
LatticeVal &IV = Values[Inst];
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;
Constant *Const = IV.isConstant()
? IV.getConstant() : UndefValue::get(Inst->getType());
DOUT << " Constant: " << *Const << " = " << *Inst;
"Associative operations should have 2 args!");
// Exactly one operand should be the result of the call instruction...
"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.
return 0;
// The only user of this instruction we allow is a single return instruction.
PHINode *PN = cast<PHINode>(I);
std::set<BasicBlock*> ProcessedPreds;
for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i)
PHINode *PN = cast<PHINode>(I);
std::set<BasicBlock*> ProcessedPreds;
for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i)
- if (BlocksToExtract.count(PN->getIncomingBlock(i)))
+ if (BlocksToExtract.count(PN->getIncomingBlock(i))) {
if (ProcessedPreds.insert(PN->getIncomingBlock(i)).second)
PN->setIncomingBlock(i, codeReplacer);
else {
if (ProcessedPreds.insert(PN->getIncomingBlock(i)).second)
PN->setIncomingBlock(i, codeReplacer);
else {
PN->removeIncomingValue(i, false);
--i; --e;
}
PN->removeIncomingValue(i, false);
--i; --e;
}
}
//cerr << "NEW FUNCTION: " << *newFunction;
}
//cerr << "NEW FUNCTION: " << *newFunction;
// icmp_eq instructions that compare a value against a constant, return the
// value being compared, and stick the constant into the Values vector.
static Value *GatherConstantSetEQs(Value *V, std::vector<ConstantInt*> &Values){
// icmp_eq instructions that compare a value against a constant, return the
// value being compared, and stick the constant into the Values vector.
static Value *GatherConstantSetEQs(Value *V, std::vector<ConstantInt*> &Values){
- if (Instruction *Inst = dyn_cast<Instruction>(V))
+ if (Instruction *Inst = dyn_cast<Instruction>(V)) {
if (Inst->getOpcode() == Instruction::ICmp &&
cast<ICmpInst>(Inst)->getPredicate() == ICmpInst::ICMP_EQ) {
if (ConstantInt *C = dyn_cast<ConstantInt>(Inst->getOperand(1))) {
if (Inst->getOpcode() == Instruction::ICmp &&
cast<ICmpInst>(Inst)->getPredicate() == ICmpInst::ICMP_EQ) {
if (ConstantInt *C = dyn_cast<ConstantInt>(Inst->getOperand(1))) {
if (LHS == RHS)
return LHS;
}
if (LHS == RHS)
return LHS;
}
// setne instructions that compare a value against a constant, return the value
// being compared, and stick the constant into the Values vector.
static Value *GatherConstantSetNEs(Value *V, std::vector<ConstantInt*> &Values){
// setne instructions that compare a value against a constant, return the value
// being compared, and stick the constant into the Values vector.
static Value *GatherConstantSetNEs(Value *V, std::vector<ConstantInt*> &Values){
- if (Instruction *Inst = dyn_cast<Instruction>(V))
+ if (Instruction *Inst = dyn_cast<Instruction>(V)) {
if (Inst->getOpcode() == Instruction::ICmp &&
cast<ICmpInst>(Inst)->getPredicate() == ICmpInst::ICMP_NE) {
if (ConstantInt *C = dyn_cast<ConstantInt>(Inst->getOperand(1))) {
if (Inst->getOpcode() == Instruction::ICmp &&
cast<ICmpInst>(Inst)->getPredicate() == ICmpInst::ICMP_NE) {
if (ConstantInt *C = dyn_cast<ConstantInt>(Inst->getOperand(1))) {
if (LHS == RHS)
return LHS;
}
if (LHS == RHS)
return LHS;
}
ConstantInt *TIV = 0;
BasicBlock *TIBB = TI->getParent();
for (unsigned i = 0, e = PredCases.size(); i != e; ++i)
ConstantInt *TIV = 0;
BasicBlock *TIBB = TI->getParent();
for (unsigned i = 0, e = PredCases.size(); i != e; ++i)
- if (PredCases[i].second == TIBB)
+ if (PredCases[i].second == TIBB) {
if (TIV == 0)
TIV = PredCases[i].first;
else
return false; // Cannot handle multiple values coming to this block.
if (TIV == 0)
TIV = PredCases[i].first;
else
return false; // Cannot handle multiple values coming to this block.
assert(TIV && "No edge from pred to succ?");
// Okay, we found the one constant that our value can be if we get into TI's
assert(TIV && "No edge from pred to succ?");
// Okay, we found the one constant that our value can be if we get into TI's
"Can't Simplify entry block!");
// Remove basic blocks that have no predecessors... which are unreachable.
"Can't Simplify entry block!");
// Remove basic blocks that have no predecessors... which are unreachable.
- if (pred_begin(BB) == pred_end(BB) ||
- *pred_begin(BB) == BB && ++pred_begin(BB) == pred_end(BB)) {
+ if ((pred_begin(BB) == pred_end(BB)) ||
+ (*pred_begin(BB) == BB && ++pred_begin(BB) == pred_end(BB))) {
DOUT << "Removing BB: \n" << *BB;
// Loop through all of our successors and make sure they know that one
DOUT << "Removing BB: \n" << *BB;
// Loop through all of our successors and make sure they know that one
SmallVector<BranchInst*, 8> CondBranchPreds;
for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) {
TerminatorInst *PTI = (*PI)->getTerminator();
SmallVector<BranchInst*, 8> CondBranchPreds;
for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) {
TerminatorInst *PTI = (*PI)->getTerminator();
- if (BranchInst *BI = dyn_cast<BranchInst>(PTI))
+ if (BranchInst *BI = dyn_cast<BranchInst>(PTI)) {
if (BI->isUnconditional())
UncondBranchPreds.push_back(*PI);
else
CondBranchPreds.push_back(BI);
if (BI->isUnconditional())
UncondBranchPreds.push_back(*PI);
else
CondBranchPreds.push_back(BI);
}
// If we found some, do the transformation!
}
// If we found some, do the transformation!