mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-18 22:38:56 +00:00
Fold a lot of code into two cases: binary instructions and ternary instructions.
This saves many lines of code duplication. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37759 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6595cb3000
commit
7b317d2f59
@ -679,153 +679,75 @@ void GVNPRE::clean(SmallPtrSet<Value*, 32>& set) {
|
|||||||
for (unsigned i = 0; i < worklist.size(); ++i) {
|
for (unsigned i = 0; i < worklist.size(); ++i) {
|
||||||
Value* v = worklist[i];
|
Value* v = worklist[i];
|
||||||
|
|
||||||
if (BinaryOperator* BO = dyn_cast<BinaryOperator>(v)) {
|
// Handle binary ops
|
||||||
bool lhsValid = !isa<Instruction>(BO->getOperand(0));
|
if (isa<BinaryOperator>(v) || isa<CmpInst>(v) ||
|
||||||
|
isa<ExtractElementInst>(v)) {
|
||||||
|
User* U = cast<User>(v);
|
||||||
|
|
||||||
|
bool lhsValid = !isa<Instruction>(U->getOperand(0));
|
||||||
if (!lhsValid)
|
if (!lhsValid)
|
||||||
for (SmallPtrSet<Value*, 32>::iterator I = set.begin(), E = set.end();
|
for (SmallPtrSet<Value*, 32>::iterator I = set.begin(), E = set.end();
|
||||||
I != E; ++I)
|
I != E; ++I)
|
||||||
if (VN.lookup(*I) == VN.lookup(BO->getOperand(0))) {
|
if (VN.lookup(*I) == VN.lookup(U->getOperand(0))) {
|
||||||
lhsValid = true;
|
lhsValid = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (lhsValid)
|
if (lhsValid)
|
||||||
lhsValid = !dependsOnInvoke(BO->getOperand(0));
|
lhsValid = !dependsOnInvoke(U->getOperand(0));
|
||||||
|
|
||||||
bool rhsValid = !isa<Instruction>(BO->getOperand(1));
|
bool rhsValid = !isa<Instruction>(U->getOperand(1));
|
||||||
if (!rhsValid)
|
if (!rhsValid)
|
||||||
for (SmallPtrSet<Value*, 32>::iterator I = set.begin(), E = set.end();
|
for (SmallPtrSet<Value*, 32>::iterator I = set.begin(), E = set.end();
|
||||||
I != E; ++I)
|
I != E; ++I)
|
||||||
if (VN.lookup(*I) == VN.lookup(BO->getOperand(1))) {
|
if (VN.lookup(*I) == VN.lookup(U->getOperand(1))) {
|
||||||
rhsValid = true;
|
rhsValid = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (rhsValid)
|
if (rhsValid)
|
||||||
rhsValid = !dependsOnInvoke(BO->getOperand(1));
|
rhsValid = !dependsOnInvoke(U->getOperand(1));
|
||||||
|
|
||||||
if (!lhsValid || !rhsValid)
|
if (!lhsValid || !rhsValid)
|
||||||
set.erase(BO);
|
set.erase(U);
|
||||||
} else if (CmpInst* C = dyn_cast<CmpInst>(v)) {
|
|
||||||
bool lhsValid = !isa<Instruction>(C->getOperand(0));
|
|
||||||
if (!lhsValid)
|
|
||||||
for (SmallPtrSet<Value*, 32>::iterator I = set.begin(), E = set.end();
|
|
||||||
I != E; ++I)
|
|
||||||
if (VN.lookup(*I) == VN.lookup(C->getOperand(0))) {
|
|
||||||
lhsValid = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (lhsValid)
|
|
||||||
lhsValid = !dependsOnInvoke(C->getOperand(0));
|
|
||||||
|
|
||||||
bool rhsValid = !isa<Instruction>(C->getOperand(1));
|
|
||||||
if (!rhsValid)
|
|
||||||
for (SmallPtrSet<Value*, 32>::iterator I = set.begin(), E = set.end();
|
|
||||||
I != E; ++I)
|
|
||||||
if (VN.lookup(*I) == VN.lookup(C->getOperand(1))) {
|
|
||||||
rhsValid = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (rhsValid)
|
|
||||||
rhsValid = !dependsOnInvoke(C->getOperand(1));
|
|
||||||
|
|
||||||
if (!lhsValid || !rhsValid)
|
// Handle ternary ops
|
||||||
set.erase(C);
|
} else if (isa<ShuffleVectorInst>(v) || isa<InsertElementInst>(v)) {
|
||||||
} else if (ShuffleVectorInst* S = dyn_cast<ShuffleVectorInst>(v)) {
|
User* U = cast<User>(v);
|
||||||
bool lhsValid = !isa<Instruction>(S->getOperand(0));
|
|
||||||
|
bool lhsValid = !isa<Instruction>(U->getOperand(0));
|
||||||
if (!lhsValid)
|
if (!lhsValid)
|
||||||
for (SmallPtrSet<Value*, 32>::iterator I = set.begin(), E = set.end();
|
for (SmallPtrSet<Value*, 32>::iterator I = set.begin(), E = set.end();
|
||||||
I != E; ++I)
|
I != E; ++I)
|
||||||
if (VN.lookup(*I) == VN.lookup(S->getOperand(0))) {
|
if (VN.lookup(*I) == VN.lookup(U->getOperand(0))) {
|
||||||
lhsValid = true;
|
lhsValid = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (lhsValid)
|
if (lhsValid)
|
||||||
lhsValid = !dependsOnInvoke(S->getOperand(0));
|
lhsValid = !dependsOnInvoke(U->getOperand(0));
|
||||||
|
|
||||||
bool rhsValid = !isa<Instruction>(S->getOperand(1));
|
bool rhsValid = !isa<Instruction>(U->getOperand(1));
|
||||||
if (!rhsValid)
|
if (!rhsValid)
|
||||||
for (SmallPtrSet<Value*, 32>::iterator I = set.begin(), E = set.end();
|
for (SmallPtrSet<Value*, 32>::iterator I = set.begin(), E = set.end();
|
||||||
I != E; ++I)
|
I != E; ++I)
|
||||||
if (VN.lookup(*I) == VN.lookup(S->getOperand(1))) {
|
if (VN.lookup(*I) == VN.lookup(U->getOperand(1))) {
|
||||||
rhsValid = true;
|
rhsValid = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (rhsValid)
|
if (rhsValid)
|
||||||
rhsValid = !dependsOnInvoke(S->getOperand(1));
|
rhsValid = !dependsOnInvoke(U->getOperand(1));
|
||||||
|
|
||||||
bool thirdValid = !isa<Instruction>(S->getOperand(2));
|
bool thirdValid = !isa<Instruction>(U->getOperand(2));
|
||||||
if (!thirdValid)
|
if (!thirdValid)
|
||||||
for (SmallPtrSet<Value*, 32>::iterator I = set.begin(), E = set.end();
|
for (SmallPtrSet<Value*, 32>::iterator I = set.begin(), E = set.end();
|
||||||
I != E; ++I)
|
I != E; ++I)
|
||||||
if (VN.lookup(*I) == VN.lookup(S->getOperand(2))) {
|
if (VN.lookup(*I) == VN.lookup(U->getOperand(2))) {
|
||||||
thirdValid = true;
|
thirdValid = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (thirdValid)
|
if (thirdValid)
|
||||||
thirdValid = !dependsOnInvoke(S->getOperand(2));
|
thirdValid = !dependsOnInvoke(U->getOperand(2));
|
||||||
|
|
||||||
if (!lhsValid || !rhsValid || !thirdValid)
|
if (!lhsValid || !rhsValid || !thirdValid)
|
||||||
set.erase(C);
|
set.erase(U);
|
||||||
} else if (InsertElementInst* S = dyn_cast<InsertElementInst>(v)) {
|
|
||||||
bool lhsValid = !isa<Instruction>(S->getOperand(0));
|
|
||||||
if (!lhsValid)
|
|
||||||
for (SmallPtrSet<Value*, 32>::iterator I = set.begin(), E = set.end();
|
|
||||||
I != E; ++I)
|
|
||||||
if (VN.lookup(*I) == VN.lookup(S->getOperand(0))) {
|
|
||||||
lhsValid = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (lhsValid)
|
|
||||||
lhsValid = !dependsOnInvoke(S->getOperand(0));
|
|
||||||
|
|
||||||
bool rhsValid = !isa<Instruction>(S->getOperand(1));
|
|
||||||
if (!rhsValid)
|
|
||||||
for (SmallPtrSet<Value*, 32>::iterator I = set.begin(), E = set.end();
|
|
||||||
I != E; ++I)
|
|
||||||
if (VN.lookup(*I) == VN.lookup(S->getOperand(1))) {
|
|
||||||
rhsValid = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (rhsValid)
|
|
||||||
rhsValid = !dependsOnInvoke(S->getOperand(1));
|
|
||||||
|
|
||||||
bool thirdValid = !isa<Instruction>(S->getOperand(2));
|
|
||||||
if (!thirdValid)
|
|
||||||
for (SmallPtrSet<Value*, 32>::iterator I = set.begin(), E = set.end();
|
|
||||||
I != E; ++I)
|
|
||||||
if (VN.lookup(*I) == VN.lookup(S->getOperand(2))) {
|
|
||||||
thirdValid = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (thirdValid)
|
|
||||||
thirdValid = !dependsOnInvoke(S->getOperand(2));
|
|
||||||
|
|
||||||
if (!lhsValid || !rhsValid || !thirdValid)
|
|
||||||
set.erase(C);
|
|
||||||
} else if (ExtractElementInst* C = dyn_cast<ExtractElementInst>(v)) {
|
|
||||||
bool lhsValid = !isa<Instruction>(C->getOperand(0));
|
|
||||||
if (!lhsValid)
|
|
||||||
for (SmallPtrSet<Value*, 32>::iterator I = set.begin(), E = set.end();
|
|
||||||
I != E; ++I)
|
|
||||||
if (VN.lookup(*I) == VN.lookup(C->getOperand(0))) {
|
|
||||||
lhsValid = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (lhsValid)
|
|
||||||
lhsValid = !dependsOnInvoke(C->getOperand(0));
|
|
||||||
|
|
||||||
bool rhsValid = !isa<Instruction>(C->getOperand(1));
|
|
||||||
if (!rhsValid)
|
|
||||||
for (SmallPtrSet<Value*, 32>::iterator I = set.begin(), E = set.end();
|
|
||||||
I != E; ++I)
|
|
||||||
if (VN.lookup(*I) == VN.lookup(C->getOperand(1))) {
|
|
||||||
rhsValid = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (rhsValid)
|
|
||||||
rhsValid = !dependsOnInvoke(C->getOperand(1));
|
|
||||||
|
|
||||||
if (!lhsValid || !rhsValid)
|
|
||||||
set.erase(C);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -843,9 +765,12 @@ void GVNPRE::topo_sort(SmallPtrSet<Value*, 32>& set, std::vector<Value*>& vec) {
|
|||||||
while (!stack.empty()) {
|
while (!stack.empty()) {
|
||||||
Value* e = stack.back();
|
Value* e = stack.back();
|
||||||
|
|
||||||
if (BinaryOperator* BO = dyn_cast<BinaryOperator>(e)) {
|
// Handle binary ops
|
||||||
Value* l = find_leader(set, VN.lookup(BO->getOperand(0)));
|
if (isa<BinaryOperator>(e) || isa<CmpInst>(e) ||
|
||||||
Value* r = find_leader(set, VN.lookup(BO->getOperand(1)));
|
isa<ExtractElementInst>(e)) {
|
||||||
|
User* U = cast<User>(e);
|
||||||
|
Value* l = find_leader(set, VN.lookup(U->getOperand(0)));
|
||||||
|
Value* r = find_leader(set, VN.lookup(U->getOperand(1)));
|
||||||
|
|
||||||
if (l != 0 && isa<Instruction>(l) &&
|
if (l != 0 && isa<Instruction>(l) &&
|
||||||
visited.count(l) == 0)
|
visited.count(l) == 0)
|
||||||
@ -858,40 +783,13 @@ void GVNPRE::topo_sort(SmallPtrSet<Value*, 32>& set, std::vector<Value*>& vec) {
|
|||||||
visited.insert(e);
|
visited.insert(e);
|
||||||
stack.pop_back();
|
stack.pop_back();
|
||||||
}
|
}
|
||||||
} else if (CmpInst* C = dyn_cast<CmpInst>(e)) {
|
|
||||||
Value* l = find_leader(set, VN.lookup(C->getOperand(0)));
|
|
||||||
Value* r = find_leader(set, VN.lookup(C->getOperand(1)));
|
|
||||||
|
|
||||||
if (l != 0 && isa<Instruction>(l) &&
|
// Handle ternary ops
|
||||||
visited.count(l) == 0)
|
} else if (isa<InsertElementInst>(e) || isa<ShuffleVectorInst>(e)) {
|
||||||
stack.push_back(l);
|
User* U = cast<User>(e);
|
||||||
else if (r != 0 && isa<Instruction>(r) &&
|
Value* l = find_leader(set, VN.lookup(U->getOperand(0)));
|
||||||
visited.count(r) == 0)
|
Value* r = find_leader(set, VN.lookup(U->getOperand(1)));
|
||||||
stack.push_back(r);
|
Value* m = find_leader(set, VN.lookup(U->getOperand(2)));
|
||||||
else {
|
|
||||||
vec.push_back(e);
|
|
||||||
visited.insert(e);
|
|
||||||
stack.pop_back();
|
|
||||||
}
|
|
||||||
} else if (ExtractElementInst* C = dyn_cast<ExtractElementInst>(e)) {
|
|
||||||
Value* l = find_leader(set, VN.lookup(C->getOperand(0)));
|
|
||||||
Value* r = find_leader(set, VN.lookup(C->getOperand(1)));
|
|
||||||
|
|
||||||
if (l != 0 && isa<Instruction>(l) &&
|
|
||||||
visited.count(l) == 0)
|
|
||||||
stack.push_back(l);
|
|
||||||
else if (r != 0 && isa<Instruction>(r) &&
|
|
||||||
visited.count(r) == 0)
|
|
||||||
stack.push_back(r);
|
|
||||||
else {
|
|
||||||
vec.push_back(e);
|
|
||||||
visited.insert(e);
|
|
||||||
stack.pop_back();
|
|
||||||
}
|
|
||||||
} else if (InsertElementInst* C = dyn_cast<InsertElementInst>(e)) {
|
|
||||||
Value* l = find_leader(set, VN.lookup(C->getOperand(0)));
|
|
||||||
Value* r = find_leader(set, VN.lookup(C->getOperand(1)));
|
|
||||||
Value* m = find_leader(set, VN.lookup(C->getOperand(2)));
|
|
||||||
|
|
||||||
if (l != 0 && isa<Instruction>(l) &&
|
if (l != 0 && isa<Instruction>(l) &&
|
||||||
visited.count(l) == 0)
|
visited.count(l) == 0)
|
||||||
@ -907,25 +805,8 @@ void GVNPRE::topo_sort(SmallPtrSet<Value*, 32>& set, std::vector<Value*>& vec) {
|
|||||||
visited.insert(e);
|
visited.insert(e);
|
||||||
stack.pop_back();
|
stack.pop_back();
|
||||||
}
|
}
|
||||||
} else if (ShuffleVectorInst* C = dyn_cast<ShuffleVectorInst>(e)) {
|
|
||||||
Value* l = find_leader(set, VN.lookup(C->getOperand(0)));
|
|
||||||
Value* r = find_leader(set, VN.lookup(C->getOperand(1)));
|
|
||||||
Value* m = find_leader(set, VN.lookup(C->getOperand(2)));
|
|
||||||
|
|
||||||
if (l != 0 && isa<Instruction>(l) &&
|
// Handle opaque ops
|
||||||
visited.count(l) == 0)
|
|
||||||
stack.push_back(l);
|
|
||||||
else if (r != 0 && isa<Instruction>(r) &&
|
|
||||||
visited.count(r) == 0)
|
|
||||||
stack.push_back(r);
|
|
||||||
else if (m != 0 && isa<Instruction>(m) &&
|
|
||||||
visited.count(m) == 0)
|
|
||||||
stack.push_back(r);
|
|
||||||
else {
|
|
||||||
vec.push_back(e);
|
|
||||||
visited.insert(e);
|
|
||||||
stack.pop_back();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
visited.insert(e);
|
visited.insert(e);
|
||||||
vec.push_back(e);
|
vec.push_back(e);
|
||||||
@ -1021,7 +902,7 @@ void GVNPRE::buildsets_availout(BasicBlock::iterator I,
|
|||||||
SmallPtrSet<Value*, 32>& currTemps,
|
SmallPtrSet<Value*, 32>& currTemps,
|
||||||
BitVector& availNumbers,
|
BitVector& availNumbers,
|
||||||
BitVector& expNumbers) {
|
BitVector& expNumbers) {
|
||||||
// Handle PHI nodes...
|
// Handle PHI nodes
|
||||||
if (PHINode* p = dyn_cast<PHINode>(I)) {
|
if (PHINode* p = dyn_cast<PHINode>(I)) {
|
||||||
VN.lookup_or_add(p);
|
VN.lookup_or_add(p);
|
||||||
expNumbers.resize(VN.size());
|
expNumbers.resize(VN.size());
|
||||||
@ -1029,12 +910,14 @@ void GVNPRE::buildsets_availout(BasicBlock::iterator I,
|
|||||||
|
|
||||||
currPhis.insert(p);
|
currPhis.insert(p);
|
||||||
|
|
||||||
// Handle binary ops...
|
// Handle binary ops
|
||||||
} else if (BinaryOperator* BO = dyn_cast<BinaryOperator>(I)) {
|
} else if (isa<BinaryOperator>(I) || isa<CmpInst>(I) ||
|
||||||
Value* leftValue = BO->getOperand(0);
|
isa<ExtractElementInst>(I)) {
|
||||||
Value* rightValue = BO->getOperand(1);
|
User* U = cast<User>(I);
|
||||||
|
Value* leftValue = U->getOperand(0);
|
||||||
|
Value* rightValue = U->getOperand(1);
|
||||||
|
|
||||||
unsigned num = VN.lookup_or_add(BO);
|
unsigned num = VN.lookup_or_add(U);
|
||||||
expNumbers.resize(VN.size());
|
expNumbers.resize(VN.size());
|
||||||
availNumbers.resize(VN.size());
|
availNumbers.resize(VN.size());
|
||||||
|
|
||||||
@ -1050,47 +933,21 @@ void GVNPRE::buildsets_availout(BasicBlock::iterator I,
|
|||||||
expNumbers.set(VN.lookup(rightValue));
|
expNumbers.set(VN.lookup(rightValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!expNumbers.test(VN.lookup(BO))) {
|
if (!expNumbers.test(VN.lookup(U))) {
|
||||||
currExps.insert(BO);
|
currExps.insert(U);
|
||||||
expNumbers.set(num);
|
expNumbers.set(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle cmp ops...
|
// Handle ternary ops
|
||||||
} else if (CmpInst* C = dyn_cast<CmpInst>(I)) {
|
} else if (isa<InsertElementInst>(I) || isa<ShuffleVectorInst>(I)) {
|
||||||
Value* leftValue = C->getOperand(0);
|
User* U = cast<User>(I);
|
||||||
Value* rightValue = C->getOperand(1);
|
Value* leftValue = U->getOperand(0);
|
||||||
|
Value* rightValue = U->getOperand(1);
|
||||||
|
Value* thirdValue = U->getOperand(2);
|
||||||
|
|
||||||
VN.lookup_or_add(C);
|
VN.lookup_or_add(U);
|
||||||
|
|
||||||
unsigned num = VN.lookup_or_add(C);
|
unsigned num = VN.lookup_or_add(U);
|
||||||
expNumbers.resize(VN.size());
|
|
||||||
availNumbers.resize(VN.size());
|
|
||||||
|
|
||||||
if (isa<Instruction>(leftValue))
|
|
||||||
if (!expNumbers.test(VN.lookup(leftValue))) {
|
|
||||||
currExps.insert(leftValue);
|
|
||||||
expNumbers.set(VN.lookup(leftValue));
|
|
||||||
}
|
|
||||||
if (isa<Instruction>(rightValue))
|
|
||||||
if (!expNumbers.test(VN.lookup(rightValue))) {
|
|
||||||
currExps.insert(rightValue);
|
|
||||||
expNumbers.set(VN.lookup(rightValue));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!expNumbers.test(VN.lookup(C))) {
|
|
||||||
currExps.insert(C);
|
|
||||||
expNumbers.set(num);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle extractelemt ops
|
|
||||||
} else if (InsertElementInst* C = dyn_cast<InsertElementInst>(I)) {
|
|
||||||
Value* leftValue = C->getOperand(0);
|
|
||||||
Value* rightValue = C->getOperand(1);
|
|
||||||
Value* thirdValue = C->getOperand(2);
|
|
||||||
|
|
||||||
VN.lookup_or_add(C);
|
|
||||||
|
|
||||||
unsigned num = VN.lookup_or_add(C);
|
|
||||||
expNumbers.resize(VN.size());
|
expNumbers.resize(VN.size());
|
||||||
availNumbers.resize(VN.size());
|
availNumbers.resize(VN.size());
|
||||||
|
|
||||||
@ -1110,73 +967,13 @@ void GVNPRE::buildsets_availout(BasicBlock::iterator I,
|
|||||||
expNumbers.set(VN.lookup(thirdValue));
|
expNumbers.set(VN.lookup(thirdValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!expNumbers.test(VN.lookup(C))) {
|
if (!expNumbers.test(VN.lookup(U))) {
|
||||||
currExps.insert(C);
|
currExps.insert(U);
|
||||||
expNumbers.set(num);
|
expNumbers.set(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle shufflevector ops
|
// Handle opaque ops
|
||||||
} else if (ShuffleVectorInst* C = dyn_cast<ShuffleVectorInst>(I)) {
|
} else if (!I->isTerminator()){
|
||||||
Value* leftValue = C->getOperand(0);
|
|
||||||
Value* rightValue = C->getOperand(1);
|
|
||||||
Value* thirdValue = C->getOperand(2);
|
|
||||||
|
|
||||||
VN.lookup_or_add(C);
|
|
||||||
|
|
||||||
unsigned num = VN.lookup_or_add(C);
|
|
||||||
expNumbers.resize(VN.size());
|
|
||||||
availNumbers.resize(VN.size());
|
|
||||||
|
|
||||||
if (isa<Instruction>(leftValue))
|
|
||||||
if (!expNumbers.test(VN.lookup(leftValue))) {
|
|
||||||
currExps.insert(leftValue);
|
|
||||||
expNumbers.set(VN.lookup(leftValue));
|
|
||||||
}
|
|
||||||
if (isa<Instruction>(rightValue))
|
|
||||||
if (!expNumbers.test(VN.lookup(rightValue))) {
|
|
||||||
currExps.insert(rightValue);
|
|
||||||
expNumbers.set(VN.lookup(rightValue));
|
|
||||||
}
|
|
||||||
if (isa<Instruction>(thirdValue))
|
|
||||||
if (!expNumbers.test(VN.lookup(thirdValue))) {
|
|
||||||
currExps.insert(thirdValue);
|
|
||||||
expNumbers.set(VN.lookup(thirdValue));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!expNumbers.test(VN.lookup(C))) {
|
|
||||||
currExps.insert(C);
|
|
||||||
expNumbers.set(num);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle insertelement ops
|
|
||||||
} else if (ExtractElementInst* C = dyn_cast<ExtractElementInst>(I)) {
|
|
||||||
Value* leftValue = C->getOperand(0);
|
|
||||||
Value* rightValue = C->getOperand(1);
|
|
||||||
|
|
||||||
VN.lookup_or_add(C);
|
|
||||||
|
|
||||||
unsigned num = VN.lookup_or_add(C);
|
|
||||||
expNumbers.resize(VN.size());
|
|
||||||
availNumbers.resize(VN.size());
|
|
||||||
|
|
||||||
if (isa<Instruction>(leftValue))
|
|
||||||
if (!expNumbers.test(VN.lookup(leftValue))) {
|
|
||||||
currExps.insert(leftValue);
|
|
||||||
expNumbers.set(VN.lookup(leftValue));
|
|
||||||
}
|
|
||||||
if (isa<Instruction>(rightValue))
|
|
||||||
if (!expNumbers.test(VN.lookup(rightValue))) {
|
|
||||||
currExps.insert(rightValue);
|
|
||||||
expNumbers.set(VN.lookup(rightValue));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!expNumbers.test(VN.lookup(C))) {
|
|
||||||
currExps.insert(C);
|
|
||||||
expNumbers.set(num);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle unsupported ops
|
|
||||||
}else if (!I->isTerminator()){
|
|
||||||
VN.lookup_or_add(I);
|
VN.lookup_or_add(I);
|
||||||
expNumbers.resize(VN.size());
|
expNumbers.resize(VN.size());
|
||||||
availNumbers.resize(VN.size());
|
availNumbers.resize(VN.size());
|
||||||
@ -1401,7 +1198,8 @@ void GVNPRE::insertion_pre(Value* e, BasicBlock* BB,
|
|||||||
s2 = find_leader(availableOut[*PI], VN.lookup(U->getOperand(1)));
|
s2 = find_leader(availableOut[*PI], VN.lookup(U->getOperand(1)));
|
||||||
else
|
else
|
||||||
s2 = U->getOperand(1);
|
s2 = U->getOperand(1);
|
||||||
|
|
||||||
|
// Ternary Operators
|
||||||
Value* s3 = 0;
|
Value* s3 = 0;
|
||||||
if (isa<ShuffleVectorInst>(U) ||
|
if (isa<ShuffleVectorInst>(U) ||
|
||||||
isa<InsertElementInst>(U))
|
isa<InsertElementInst>(U))
|
||||||
@ -1566,11 +1364,6 @@ bool GVNPRE::insertion(Function& F) {
|
|||||||
workList.reserve(anticIn.size());
|
workList.reserve(anticIn.size());
|
||||||
topo_sort(anticIn, workList);
|
topo_sort(anticIn, workList);
|
||||||
|
|
||||||
//DOUT << "Merge Block: " << BB->getName() << "\n";
|
|
||||||
//DOUT << "ANTIC_IN: ";
|
|
||||||
//dump(anticIn);
|
|
||||||
//DOUT << "\n";
|
|
||||||
|
|
||||||
unsigned result = insertion_mergepoint(workList, DI, new_set);
|
unsigned result = insertion_mergepoint(workList, DI, new_set);
|
||||||
if (result & 1)
|
if (result & 1)
|
||||||
changed_function = true;
|
changed_function = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user