mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-14 09:38:40 +00:00
Make instcombine O(N) instead of O(N^2) in code where the same simplifiable constant is used many times.
Part of rdar://9471075. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131979 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8ec0c1c07b
commit
a4d4aeb387
@ -1385,7 +1385,7 @@ static bool AddReachableCodeToWorklist(BasicBlock *BB,
|
|||||||
Worklist.push_back(BB);
|
Worklist.push_back(BB);
|
||||||
|
|
||||||
SmallVector<Instruction*, 128> InstrsForInstCombineWorklist;
|
SmallVector<Instruction*, 128> InstrsForInstCombineWorklist;
|
||||||
SmallPtrSet<ConstantExpr*, 64> FoldedConstants;
|
DenseMap<ConstantExpr*, Constant*> FoldedConstants;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
BB = Worklist.pop_back_val();
|
BB = Worklist.pop_back_val();
|
||||||
@ -1422,13 +1422,14 @@ static bool AddReachableCodeToWorklist(BasicBlock *BB,
|
|||||||
ConstantExpr *CE = dyn_cast<ConstantExpr>(i);
|
ConstantExpr *CE = dyn_cast<ConstantExpr>(i);
|
||||||
if (CE == 0) continue;
|
if (CE == 0) continue;
|
||||||
|
|
||||||
// If we already folded this constant, don't try again.
|
Constant*& FoldRes = FoldedConstants[CE];
|
||||||
if (!FoldedConstants.insert(CE))
|
if (!FoldRes)
|
||||||
continue;
|
FoldRes = ConstantFoldConstantExpression(CE, TD);
|
||||||
|
if (!FoldRes)
|
||||||
|
FoldRes = CE;
|
||||||
|
|
||||||
Constant *NewC = ConstantFoldConstantExpression(CE, TD);
|
if (FoldRes != CE) {
|
||||||
if (NewC && NewC != CE) {
|
*i = FoldRes;
|
||||||
*i = NewC;
|
|
||||||
MadeIRChange = true;
|
MadeIRChange = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user