mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
[unroll] Extract the code to enqueue operansd for the worklist in the
unroll analysis into a lambda and call it. That's much simpler than duplicating all the code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229053 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
76908cba94
commit
29e00cf519
@ -509,6 +509,15 @@ public:
|
|||||||
// worklist.
|
// worklist.
|
||||||
SmallPtrSet<Instruction *, 4> OperandSet;
|
SmallPtrSet<Instruction *, 4> OperandSet;
|
||||||
|
|
||||||
|
// Lambda to enque operands onto the worklist.
|
||||||
|
auto EnqueueOperands = [&](Instruction &I) {
|
||||||
|
OperandSet.clear();
|
||||||
|
for (auto *Op : I.operand_values())
|
||||||
|
if (auto *OpI = dyn_cast<Instruction>(Op))
|
||||||
|
if (OperandSet.insert(OpI).second)
|
||||||
|
Worklist.push_back(OpI);
|
||||||
|
};
|
||||||
|
|
||||||
// Start by initializing worklist with simplified instructions.
|
// Start by initializing worklist with simplified instructions.
|
||||||
for (auto &FoldedKeyValue : SimplifiedValues)
|
for (auto &FoldedKeyValue : SimplifiedValues)
|
||||||
if (auto *FoldedInst = dyn_cast<Instruction>(FoldedKeyValue.first)) {
|
if (auto *FoldedInst = dyn_cast<Instruction>(FoldedKeyValue.first)) {
|
||||||
@ -516,11 +525,7 @@ public:
|
|||||||
|
|
||||||
// Add each instruction operand of this dead instruction to the
|
// Add each instruction operand of this dead instruction to the
|
||||||
// worklist.
|
// worklist.
|
||||||
OperandSet.clear();
|
EnqueueOperands(*FoldedInst);
|
||||||
for (auto *Op : FoldedInst->operand_values())
|
|
||||||
if (auto *OpI = dyn_cast<Instruction>(Op))
|
|
||||||
if (OperandSet.insert(OpI).second)
|
|
||||||
Worklist.push_back(OpI);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a definition of an insn is only used by simplified or dead
|
// If a definition of an insn is only used by simplified or dead
|
||||||
@ -545,11 +550,7 @@ public:
|
|||||||
if (AllUsersFolded) {
|
if (AllUsersFolded) {
|
||||||
NumberOfOptimizedInstructions += TTI.getUserCost(I);
|
NumberOfOptimizedInstructions += TTI.getUserCost(I);
|
||||||
DeadInstructions.insert(I);
|
DeadInstructions.insert(I);
|
||||||
OperandSet.clear();
|
EnqueueOperands(*I);
|
||||||
for (auto *Op : I->operand_values())
|
|
||||||
if (auto *OpI = dyn_cast<Instruction>(Op))
|
|
||||||
if (OperandSet.insert(OpI).second)
|
|
||||||
Worklist.push_back(OpI);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NumberOfOptimizedInstructions;
|
return NumberOfOptimizedInstructions;
|
||||||
|
Loading…
Reference in New Issue
Block a user