Simplify some code.

llvm-svn: 84533
This commit is contained in:
Owen Anderson 2009-10-19 21:14:57 +00:00
parent 241c56bee6
commit 4954f8ef02

View File

@ -429,31 +429,24 @@ uint32_t ValueTable::lookup_or_add(Value *V) {
if (CallInst* C = dyn_cast<CallInst>(V)) { if (CallInst* C = dyn_cast<CallInst>(V)) {
if (AA->doesNotAccessMemory(C)) { if (AA->doesNotAccessMemory(C)) {
Expression e = create_expression(C); Expression exp = create_expression(C);
uint32_t& e = expressionNumbering[exp];
DenseMap<Expression, uint32_t>::iterator EI = expressionNumbering.find(e); if (!e) e = nextValueNumber++;
if (EI != expressionNumbering.end()) { valueNumbering[V] = e;
valueNumbering.insert(std::make_pair(V, EI->second)); return e;
return EI->second;
} else {
expressionNumbering.insert(std::make_pair(e, nextValueNumber));
valueNumbering.insert(std::make_pair(V, nextValueNumber));
return nextValueNumber++;
}
} else if (AA->onlyReadsMemory(C)) { } else if (AA->onlyReadsMemory(C)) {
Expression e = create_expression(C); Expression exp = create_expression(C);
uint32_t& e = expressionNumbering[exp];
if (expressionNumbering.find(e) == expressionNumbering.end()) { if (!e) {
expressionNumbering.insert(std::make_pair(e, nextValueNumber)); e = nextValueNumber++;
valueNumbering.insert(std::make_pair(V, nextValueNumber)); valueNumbering[V] = e;
return nextValueNumber++; return e;
} }
MemDepResult local_dep = MD->getDependency(C); MemDepResult local_dep = MD->getDependency(C);
if (!local_dep.isDef() && !local_dep.isNonLocal()) { if (!local_dep.isDef() && !local_dep.isNonLocal()) {
valueNumbering.insert(std::make_pair(V, nextValueNumber)); valueNumbering[V] = nextValueNumber;
return nextValueNumber++; return nextValueNumber++;
} }
@ -461,7 +454,7 @@ uint32_t ValueTable::lookup_or_add(Value *V) {
CallInst* local_cdep = cast<CallInst>(local_dep.getInst()); CallInst* local_cdep = cast<CallInst>(local_dep.getInst());
if (local_cdep->getNumOperands() != C->getNumOperands()) { if (local_cdep->getNumOperands() != C->getNumOperands()) {
valueNumbering.insert(std::make_pair(V, nextValueNumber)); valueNumbering[V] = nextValueNumber;
return nextValueNumber++; return nextValueNumber++;
} }
@ -469,13 +462,13 @@ uint32_t ValueTable::lookup_or_add(Value *V) {
uint32_t c_vn = lookup_or_add(C->getOperand(i)); uint32_t c_vn = lookup_or_add(C->getOperand(i));
uint32_t cd_vn = lookup_or_add(local_cdep->getOperand(i)); uint32_t cd_vn = lookup_or_add(local_cdep->getOperand(i));
if (c_vn != cd_vn) { if (c_vn != cd_vn) {
valueNumbering.insert(std::make_pair(V, nextValueNumber)); valueNumbering[V] = nextValueNumber;
return nextValueNumber++; return nextValueNumber++;
} }
} }
uint32_t v = lookup_or_add(local_cdep); uint32_t v = lookup_or_add(local_cdep);
valueNumbering.insert(std::make_pair(V, v)); valueNumbering[V] = v;
return v; return v;
} }
@ -513,137 +506,81 @@ uint32_t ValueTable::lookup_or_add(Value *V) {
} }
if (!cdep) { if (!cdep) {
valueNumbering.insert(std::make_pair(V, nextValueNumber)); valueNumbering[V] = nextValueNumber;
return nextValueNumber++; return nextValueNumber++;
} }
if (cdep->getNumOperands() != C->getNumOperands()) { if (cdep->getNumOperands() != C->getNumOperands()) {
valueNumbering.insert(std::make_pair(V, nextValueNumber)); valueNumbering[V] = nextValueNumber;
return nextValueNumber++; return nextValueNumber++;
} }
for (unsigned i = 1; i < C->getNumOperands(); ++i) { for (unsigned i = 1; i < C->getNumOperands(); ++i) {
uint32_t c_vn = lookup_or_add(C->getOperand(i)); uint32_t c_vn = lookup_or_add(C->getOperand(i));
uint32_t cd_vn = lookup_or_add(cdep->getOperand(i)); uint32_t cd_vn = lookup_or_add(cdep->getOperand(i));
if (c_vn != cd_vn) { if (c_vn != cd_vn) {
valueNumbering.insert(std::make_pair(V, nextValueNumber)); valueNumbering[V] = nextValueNumber;
return nextValueNumber++; return nextValueNumber++;
} }
} }
uint32_t v = lookup_or_add(cdep); uint32_t v = lookup_or_add(cdep);
valueNumbering.insert(std::make_pair(V, v)); valueNumbering[V] = v;
return v; return v;
} else { } else {
valueNumbering.insert(std::make_pair(V, nextValueNumber)); valueNumbering[V] = nextValueNumber;
return nextValueNumber++; return nextValueNumber++;
} }
} else if (BinaryOperator* BO = dyn_cast<BinaryOperator>(V)) { } else if (BinaryOperator* BO = dyn_cast<BinaryOperator>(V)) {
Expression e = create_expression(BO); Expression exp = create_expression(BO);
uint32_t& e = expressionNumbering[exp];
DenseMap<Expression, uint32_t>::iterator EI = expressionNumbering.find(e); if (!e) e = nextValueNumber++;
if (EI != expressionNumbering.end()) { valueNumbering[V] = e;
valueNumbering.insert(std::make_pair(V, EI->second)); return e;
return EI->second;
} else {
expressionNumbering.insert(std::make_pair(e, nextValueNumber));
valueNumbering.insert(std::make_pair(V, nextValueNumber));
return nextValueNumber++;
}
} else if (CmpInst* C = dyn_cast<CmpInst>(V)) { } else if (CmpInst* C = dyn_cast<CmpInst>(V)) {
Expression e = create_expression(C); Expression exp = create_expression(C);
uint32_t& e = expressionNumbering[exp];
DenseMap<Expression, uint32_t>::iterator EI = expressionNumbering.find(e); if (!e) e = nextValueNumber++;
if (EI != expressionNumbering.end()) { valueNumbering[V] = e;
valueNumbering.insert(std::make_pair(V, EI->second)); return e;
return EI->second;
} else {
expressionNumbering.insert(std::make_pair(e, nextValueNumber));
valueNumbering.insert(std::make_pair(V, nextValueNumber));
return nextValueNumber++;
}
} else if (ShuffleVectorInst* U = dyn_cast<ShuffleVectorInst>(V)) { } else if (ShuffleVectorInst* U = dyn_cast<ShuffleVectorInst>(V)) {
Expression e = create_expression(U); Expression exp = create_expression(U);
uint32_t& e = expressionNumbering[exp];
DenseMap<Expression, uint32_t>::iterator EI = expressionNumbering.find(e); if (!e) e = nextValueNumber++;
if (EI != expressionNumbering.end()) { valueNumbering[V] = e;
valueNumbering.insert(std::make_pair(V, EI->second)); return e;
return EI->second;
} else {
expressionNumbering.insert(std::make_pair(e, nextValueNumber));
valueNumbering.insert(std::make_pair(V, nextValueNumber));
return nextValueNumber++;
}
} else if (ExtractElementInst* U = dyn_cast<ExtractElementInst>(V)) { } else if (ExtractElementInst* U = dyn_cast<ExtractElementInst>(V)) {
Expression e = create_expression(U); Expression exp = create_expression(U);
uint32_t& e = expressionNumbering[exp];
DenseMap<Expression, uint32_t>::iterator EI = expressionNumbering.find(e); if (!e) e = nextValueNumber++;
if (EI != expressionNumbering.end()) { valueNumbering[V] = e;
valueNumbering.insert(std::make_pair(V, EI->second)); return e;
return EI->second;
} else {
expressionNumbering.insert(std::make_pair(e, nextValueNumber));
valueNumbering.insert(std::make_pair(V, nextValueNumber));
return nextValueNumber++;
}
} else if (InsertElementInst* U = dyn_cast<InsertElementInst>(V)) { } else if (InsertElementInst* U = dyn_cast<InsertElementInst>(V)) {
Expression e = create_expression(U); Expression exp = create_expression(U);
uint32_t& e = expressionNumbering[exp];
DenseMap<Expression, uint32_t>::iterator EI = expressionNumbering.find(e); if (!e) e = nextValueNumber++;
if (EI != expressionNumbering.end()) { valueNumbering[V] = e;
valueNumbering.insert(std::make_pair(V, EI->second)); return e;
return EI->second;
} else {
expressionNumbering.insert(std::make_pair(e, nextValueNumber));
valueNumbering.insert(std::make_pair(V, nextValueNumber));
return nextValueNumber++;
}
} else if (SelectInst* U = dyn_cast<SelectInst>(V)) { } else if (SelectInst* U = dyn_cast<SelectInst>(V)) {
Expression e = create_expression(U); Expression exp = create_expression(U);
uint32_t& e = expressionNumbering[exp];
DenseMap<Expression, uint32_t>::iterator EI = expressionNumbering.find(e); if (!e) e = nextValueNumber++;
if (EI != expressionNumbering.end()) { valueNumbering[V] = e;
valueNumbering.insert(std::make_pair(V, EI->second)); return e;
return EI->second;
} else {
expressionNumbering.insert(std::make_pair(e, nextValueNumber));
valueNumbering.insert(std::make_pair(V, nextValueNumber));
return nextValueNumber++;
}
} else if (CastInst* U = dyn_cast<CastInst>(V)) { } else if (CastInst* U = dyn_cast<CastInst>(V)) {
Expression e = create_expression(U); Expression exp = create_expression(U);
uint32_t& e = expressionNumbering[exp];
DenseMap<Expression, uint32_t>::iterator EI = expressionNumbering.find(e); if (!e) e = nextValueNumber++;
if (EI != expressionNumbering.end()) { valueNumbering[V] = e;
valueNumbering.insert(std::make_pair(V, EI->second)); return e;
return EI->second;
} else {
expressionNumbering.insert(std::make_pair(e, nextValueNumber));
valueNumbering.insert(std::make_pair(V, nextValueNumber));
return nextValueNumber++;
}
} else if (GetElementPtrInst* U = dyn_cast<GetElementPtrInst>(V)) { } else if (GetElementPtrInst* U = dyn_cast<GetElementPtrInst>(V)) {
Expression e = create_expression(U); Expression exp = create_expression(U);
uint32_t& e = expressionNumbering[exp];
DenseMap<Expression, uint32_t>::iterator EI = expressionNumbering.find(e); if (!e) e = nextValueNumber++;
if (EI != expressionNumbering.end()) { valueNumbering[V] = e;
valueNumbering.insert(std::make_pair(V, EI->second)); return e;
return EI->second;
} else {
expressionNumbering.insert(std::make_pair(e, nextValueNumber));
valueNumbering.insert(std::make_pair(V, nextValueNumber));
return nextValueNumber++;
}
} else { } else {
valueNumbering.insert(std::make_pair(V, nextValueNumber)); valueNumbering[V] = nextValueNumber;
return nextValueNumber++; return nextValueNumber++;
} }
} }