mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-09 10:31:14 +00:00
Cleanup. Refactor out the applying of value ranges to its own method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35719 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b01c77e137
commit
f3a9e368f6
@ -461,7 +461,6 @@ namespace {
|
|||||||
ToRepoint.push_back(V);
|
ToRepoint.push_back(V);
|
||||||
|
|
||||||
if (unsigned Conflict = getNode(V, Subtree)) {
|
if (unsigned Conflict = getNode(V, Subtree)) {
|
||||||
// XXX: NodeMap.size() exceeds 68,000 entries compiling kimwitu++!
|
|
||||||
for (NodeMapType::iterator I = NodeMap.begin(), E = NodeMap.end();
|
for (NodeMapType::iterator I = NodeMap.begin(), E = NodeMap.end();
|
||||||
I != E; ++I) {
|
I != E; ++I) {
|
||||||
if (I->index == Conflict && Subtree->DominatedBy(I->Subtree))
|
if (I->index == Conflict && Subtree->DominatedBy(I->Subtree))
|
||||||
@ -512,15 +511,17 @@ namespace {
|
|||||||
// Suppose we're adding %n1 < %n2. Find all the %a < %n1 and
|
// Suppose we're adding %n1 < %n2. Find all the %a < %n1 and
|
||||||
// add %a < %n2 too. This keeps the graph fully connected.
|
// add %a < %n2 too. This keeps the graph fully connected.
|
||||||
if (LV1 != NE) {
|
if (LV1 != NE) {
|
||||||
// Someone with a head for this sort of logic, please review this.
|
// Break up the relationship into signed and unsigned comparison parts.
|
||||||
// Given that %x SLTUGT %y and %a SLE %x, what is the relationship
|
// If the signed parts of %a op1 %n1 match that of %n1 op2 %n2, and
|
||||||
// between %a and %y? I believe the below code is correct, but I don't
|
// op1 and op2 aren't NE, then add %a op3 %n2. The new relationship
|
||||||
// think it's the most efficient solution.
|
// should have the EQ_BIT iff it's set for both op1 and op2.
|
||||||
|
|
||||||
unsigned LV1_s = LV1 & (SLT_BIT|SGT_BIT);
|
unsigned LV1_s = LV1 & (SLT_BIT|SGT_BIT);
|
||||||
unsigned LV1_u = LV1 & (ULT_BIT|UGT_BIT);
|
unsigned LV1_u = LV1 & (ULT_BIT|UGT_BIT);
|
||||||
|
|
||||||
for (Node::iterator I = N1->begin(), E = N1->end(); I != E; ++I) {
|
for (Node::iterator I = N1->begin(), E = N1->end(); I != E; ++I) {
|
||||||
if (I->LV != NE && I->To != n2) {
|
if (I->LV != NE && I->To != n2) {
|
||||||
|
|
||||||
ETNode *Local_Subtree = NULL;
|
ETNode *Local_Subtree = NULL;
|
||||||
if (Subtree->DominatedBy(I->Subtree))
|
if (Subtree->DominatedBy(I->Subtree))
|
||||||
Local_Subtree = Subtree;
|
Local_Subtree = Subtree;
|
||||||
@ -535,7 +536,6 @@ namespace {
|
|||||||
|
|
||||||
if (LV1_s != (SLT_BIT|SGT_BIT) && ILV_s == LV1_s)
|
if (LV1_s != (SLT_BIT|SGT_BIT) && ILV_s == LV1_s)
|
||||||
new_relationship |= ILV_s;
|
new_relationship |= ILV_s;
|
||||||
|
|
||||||
if (LV1_u != (ULT_BIT|UGT_BIT) && ILV_u == LV1_u)
|
if (LV1_u != (ULT_BIT|UGT_BIT) && ILV_u == LV1_u)
|
||||||
new_relationship |= ILV_u;
|
new_relationship |= ILV_u;
|
||||||
|
|
||||||
@ -719,10 +719,9 @@ namespace {
|
|||||||
// Also, we have to tighten any edge that Subtree dominates.
|
// Also, we have to tighten any edge that Subtree dominates.
|
||||||
for (iterator B = begin(); I->V == V; --I) {
|
for (iterator B = begin(); I->V == V; --I) {
|
||||||
if (I->Subtree->DominatedBy(Subtree)) {
|
if (I->Subtree->DominatedBy(Subtree)) {
|
||||||
CR = CR.intersectWith(I->CR);
|
I->CR = CR.intersectWith(I->CR);
|
||||||
assert(!CR.isEmptySet() &&
|
assert(!I->CR.isEmptySet() &&
|
||||||
"Empty intersection of ConstantRanges!");
|
"Empty intersection of ConstantRanges!");
|
||||||
I->CR = CR;
|
|
||||||
}
|
}
|
||||||
if (I == B) break;
|
if (I == B) break;
|
||||||
}
|
}
|
||||||
@ -906,7 +905,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void addToWorklist(Value *V, const APInt *I, ICmpInst::Predicate Pred,
|
void addToWorklist(Value *V, Constant *C, ICmpInst::Predicate Pred,
|
||||||
VRPSolver *VRP);
|
VRPSolver *VRP);
|
||||||
|
|
||||||
void mergeInto(Value **I, unsigned n, Value *New, ETNode *Subtree,
|
void mergeInto(Value **I, unsigned n, Value *New, ETNode *Subtree,
|
||||||
@ -927,11 +926,27 @@ namespace {
|
|||||||
|
|
||||||
if (Merged.isFullSet() || Merged == CR_New) return;
|
if (Merged.isFullSet() || Merged == CR_New) return;
|
||||||
|
|
||||||
if (Merged.isSingleElement())
|
applyRange(New, Merged, Subtree, VRP);
|
||||||
addToWorklist(New, Merged.getSingleElement(),
|
}
|
||||||
|
|
||||||
|
void applyRange(Value *V, const ConstantRange &CR, ETNode *Subtree,
|
||||||
|
VRPSolver *VRP) {
|
||||||
|
assert(isCanonical(V, Subtree, VRP) && "Value not canonical.");
|
||||||
|
|
||||||
|
if (const APInt *I = CR.getSingleElement()) {
|
||||||
|
const Type *Ty = V->getType();
|
||||||
|
if (Ty->isInteger()) {
|
||||||
|
addToWorklist(V, ConstantInt::get(*I), ICmpInst::ICMP_EQ, VRP);
|
||||||
|
return;
|
||||||
|
} else if (const PointerType *PTy = dyn_cast<PointerType>(Ty)) {
|
||||||
|
assert(*I == 0 && "Pointer is null but not zero?");
|
||||||
|
addToWorklist(V, ConstantPointerNull::get(PTy),
|
||||||
ICmpInst::ICMP_EQ, VRP);
|
ICmpInst::ICMP_EQ, VRP);
|
||||||
else
|
return;
|
||||||
update(New, Merged, Subtree);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
update(V, CR, Subtree);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addInequality(Value *V1, Value *V2, ETNode *Subtree, LatticeVal LV,
|
void addInequality(Value *V1, Value *V2, ETNode *Subtree, LatticeVal LV,
|
||||||
@ -953,25 +968,15 @@ namespace {
|
|||||||
|
|
||||||
if (!CR1.isSingleElement()) {
|
if (!CR1.isSingleElement()) {
|
||||||
ConstantRange NewCR1 = CR1.intersectWith(create(LV, CR2));
|
ConstantRange NewCR1 = CR1.intersectWith(create(LV, CR2));
|
||||||
if (NewCR1 != CR1) {
|
if (NewCR1 != CR1)
|
||||||
if (NewCR1.isSingleElement())
|
applyRange(V1, NewCR1, Subtree, VRP);
|
||||||
addToWorklist(V1, NewCR1.getSingleElement(),
|
|
||||||
ICmpInst::ICMP_EQ, VRP);
|
|
||||||
else
|
|
||||||
update(V1, NewCR1, Subtree);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CR2.isSingleElement()) {
|
if (!CR2.isSingleElement()) {
|
||||||
ConstantRange NewCR2 = CR2.intersectWith(create(reversePredicate(LV),
|
ConstantRange NewCR2 = CR2.intersectWith(create(reversePredicate(LV),
|
||||||
CR1));
|
CR1));
|
||||||
if (NewCR2 != CR2) {
|
if (NewCR2 != CR2)
|
||||||
if (NewCR2.isSingleElement())
|
applyRange(V2, NewCR2, Subtree, VRP);
|
||||||
addToWorklist(V2, NewCR2.getSingleElement(),
|
|
||||||
ICmpInst::ICMP_EQ, VRP);
|
|
||||||
else
|
|
||||||
update(V2, NewCR2, Subtree);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1847,9 +1852,9 @@ namespace {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void ValueRanges::addToWorklist(Value *V, const APInt *I,
|
void ValueRanges::addToWorklist(Value *V, Constant *C,
|
||||||
ICmpInst::Predicate Pred, VRPSolver *VRP) {
|
ICmpInst::Predicate Pred, VRPSolver *VRP) {
|
||||||
VRP->add(V, ConstantInt::get(*I), Pred, VRP->TopInst);
|
VRP->add(V, C, Pred, VRP->TopInst);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
Loading…
Reference in New Issue
Block a user