mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-25 00:24:26 +00:00
licm is wasting time hoisting constant foldable operations,
instead of hoisting them, just fold them away. This occurs in the testcase for PR8041, for example. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112669 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -36,11 +36,11 @@
|
||||
#include "llvm/DerivedTypes.h"
|
||||
#include "llvm/IntrinsicInst.h"
|
||||
#include "llvm/Instructions.h"
|
||||
#include "llvm/Target/TargetData.h"
|
||||
#include "llvm/Analysis/LoopInfo.h"
|
||||
#include "llvm/Analysis/LoopPass.h"
|
||||
#include "llvm/Analysis/AliasAnalysis.h"
|
||||
#include "llvm/Analysis/AliasSetTracker.h"
|
||||
#include "llvm/Analysis/ConstantFolding.h"
|
||||
#include "llvm/Analysis/LoopInfo.h"
|
||||
#include "llvm/Analysis/LoopPass.h"
|
||||
#include "llvm/Analysis/Dominators.h"
|
||||
#include "llvm/Analysis/ScalarEvolution.h"
|
||||
#include "llvm/Transforms/Utils/Local.h"
|
||||
@ -353,6 +353,18 @@ void LICM::HoistRegion(DomTreeNode *N) {
|
||||
for (BasicBlock::iterator II = BB->begin(), E = BB->end(); II != E; ) {
|
||||
Instruction &I = *II++;
|
||||
|
||||
// Try constant folding this instruction. If all the operands are
|
||||
// constants, it is technically hoistable, but it would be better to just
|
||||
// fold it.
|
||||
if (Constant *C = ConstantFoldInstruction(&I)) {
|
||||
DEBUG(dbgs() << "LICM folding inst: " << I << " --> " << *C << '\n');
|
||||
CurAST->copyValue(&I, C);
|
||||
CurAST->deleteValue(&I);
|
||||
I.replaceAllUsesWith(C);
|
||||
I.eraseFromParent();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Try hoisting the instruction out to the preheader. We can only do this
|
||||
// if all of the operands of the instruction are loop invariant and if it
|
||||
// is safe to hoist the instruction.
|
||||
@ -360,7 +372,7 @@ void LICM::HoistRegion(DomTreeNode *N) {
|
||||
if (isLoopInvariantInst(I) && canSinkOrHoistInst(I) &&
|
||||
isSafeToExecuteUnconditionally(I))
|
||||
hoist(I);
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<DomTreeNode*> &Children = N->getChildren();
|
||||
for (unsigned i = 0, e = Children.size(); i != e; ++i)
|
||||
|
Reference in New Issue
Block a user