mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-01 00:11:00 +00:00
factor statistic updating better.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92362 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4760467ff2
commit
9fdaefad58
@ -563,17 +563,13 @@ static Value *OptimizeAndOrXor(unsigned Opcode, std::vector<ValueEntry> &Ops) {
|
|||||||
Value *X = BinaryOperator::getNotArgument(Ops[i].Op);
|
Value *X = BinaryOperator::getNotArgument(Ops[i].Op);
|
||||||
unsigned FoundX = FindInOperandList(Ops, i, X);
|
unsigned FoundX = FindInOperandList(Ops, i, X);
|
||||||
if (FoundX != i) {
|
if (FoundX != i) {
|
||||||
if (Opcode == Instruction::And) { // ...&X&~X = 0
|
if (Opcode == Instruction::And) // ...&X&~X = 0
|
||||||
++NumAnnihil;
|
|
||||||
return Constant::getNullValue(X->getType());
|
return Constant::getNullValue(X->getType());
|
||||||
}
|
|
||||||
|
|
||||||
if (Opcode == Instruction::Or) { // ...|X|~X = -1
|
if (Opcode == Instruction::Or) // ...|X|~X = -1
|
||||||
++NumAnnihil;
|
|
||||||
return Constant::getAllOnesValue(X->getType());
|
return Constant::getAllOnesValue(X->getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Next, check for duplicate pairs of values, which we assume are next to
|
// Next, check for duplicate pairs of values, which we assume are next to
|
||||||
// each other, due to our sorting criteria.
|
// each other, due to our sorting criteria.
|
||||||
@ -586,10 +582,9 @@ static Value *OptimizeAndOrXor(unsigned Opcode, std::vector<ValueEntry> &Ops) {
|
|||||||
++NumAnnihil;
|
++NumAnnihil;
|
||||||
} else {
|
} else {
|
||||||
assert(Opcode == Instruction::Xor);
|
assert(Opcode == Instruction::Xor);
|
||||||
if (e == 2) {
|
if (e == 2)
|
||||||
++NumAnnihil;
|
|
||||||
return Constant::getNullValue(Ops[0].Op->getType());
|
return Constant::getNullValue(Ops[0].Op->getType());
|
||||||
}
|
|
||||||
// ... X^X -> ...
|
// ... X^X -> ...
|
||||||
Ops.erase(Ops.begin()+i, Ops.begin()+i+2);
|
Ops.erase(Ops.begin()+i, Ops.begin()+i+2);
|
||||||
i -= 1; e -= 2;
|
i -= 1; e -= 2;
|
||||||
@ -618,10 +613,8 @@ Value *Reassociate::OptimizeAdd(std::vector<ValueEntry> &Ops) {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Remove X and -X from the operand list.
|
// Remove X and -X from the operand list.
|
||||||
if (Ops.size() == 2) {
|
if (Ops.size() == 2)
|
||||||
++NumAnnihil;
|
|
||||||
return Constant::getNullValue(X->getType());
|
return Constant::getNullValue(X->getType());
|
||||||
}
|
|
||||||
|
|
||||||
Ops.erase(Ops.begin()+i);
|
Ops.erase(Ops.begin()+i);
|
||||||
if (i < FoundX)
|
if (i < FoundX)
|
||||||
@ -657,10 +650,8 @@ Value *Reassociate::OptimizeExpression(BinaryOperator *I,
|
|||||||
switch (Opcode) {
|
switch (Opcode) {
|
||||||
default: break;
|
default: break;
|
||||||
case Instruction::And:
|
case Instruction::And:
|
||||||
if (CstVal->isZero()) { // ... & 0 -> 0
|
if (CstVal->isZero()) // ... & 0 -> 0
|
||||||
++NumAnnihil;
|
|
||||||
return CstVal;
|
return CstVal;
|
||||||
}
|
|
||||||
if (CstVal->isAllOnesValue()) // ... & -1 -> ...
|
if (CstVal->isAllOnesValue()) // ... & -1 -> ...
|
||||||
Ops.pop_back();
|
Ops.pop_back();
|
||||||
break;
|
break;
|
||||||
@ -674,10 +665,8 @@ Value *Reassociate::OptimizeExpression(BinaryOperator *I,
|
|||||||
Ops.pop_back(); // ... * 1 -> ...
|
Ops.pop_back(); // ... * 1 -> ...
|
||||||
break;
|
break;
|
||||||
case Instruction::Or:
|
case Instruction::Or:
|
||||||
if (CstVal->isAllOnesValue()) { // ... | -1 -> -1
|
if (CstVal->isAllOnesValue()) // ... | -1 -> -1
|
||||||
++NumAnnihil;
|
|
||||||
return CstVal;
|
return CstVal;
|
||||||
}
|
|
||||||
// FALLTHROUGH!
|
// FALLTHROUGH!
|
||||||
case Instruction::Add:
|
case Instruction::Add:
|
||||||
case Instruction::Xor:
|
case Instruction::Xor:
|
||||||
@ -883,6 +872,7 @@ void Reassociate::ReassociateExpression(BinaryOperator *I) {
|
|||||||
DEBUG(errs() << "Reassoc to scalar: " << *V << "\n");
|
DEBUG(errs() << "Reassoc to scalar: " << *V << "\n");
|
||||||
I->replaceAllUsesWith(V);
|
I->replaceAllUsesWith(V);
|
||||||
RemoveDeadBinaryOp(I);
|
RemoveDeadBinaryOp(I);
|
||||||
|
++NumAnnihil;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user