From: Dan Gohman Date: Sat, 31 Oct 2009 14:35:41 +0000 (+0000) Subject: Remove CodeGenLICM. It's largely obsoleted by MachineLICM's new ability X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=9f476e3179713a1e93bbf634855b85a93f8653cd Remove CodeGenLICM. It's largely obsoleted by MachineLICM's new ability to unfold loop-invariant loads. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85657 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/LinkAllPasses.h b/include/llvm/LinkAllPasses.h index 60384256fa3..bcb98c16ad0 100644 --- a/include/llvm/LinkAllPasses.h +++ b/include/llvm/LinkAllPasses.h @@ -123,7 +123,6 @@ namespace { (void) llvm::createNullProfilerRSPass(); (void) llvm::createRSProfilingPass(); (void) llvm::createInstCountPass(); - (void) llvm::createCodeGenLICMPass(); (void) llvm::createCodeGenPreparePass(); (void) llvm::createGVNPass(); (void) llvm::createMemCpyOptPass(); diff --git a/include/llvm/Transforms/Scalar.h b/include/llvm/Transforms/Scalar.h index e01b5dd746d..523a8f45a85 100644 --- a/include/llvm/Transforms/Scalar.h +++ b/include/llvm/Transforms/Scalar.h @@ -305,12 +305,6 @@ FunctionPass *createSimplifyHalfPowrLibCallsPass(); // FunctionPass *createCodeGenPreparePass(const TargetLowering *TLI = 0); -//===----------------------------------------------------------------------===// -// -// CodeGenLICM - This pass performs late LICM; hoisting constants out of loops. -// -Pass *createCodeGenLICMPass(); - //===----------------------------------------------------------------------===// // // InstructionNamer - Give any unnamed non-void instructions "tmp" names. diff --git a/lib/CodeGen/LLVMTargetMachine.cpp b/lib/CodeGen/LLVMTargetMachine.cpp index e58a9ca82c6..1234cb7fd9a 100644 --- a/lib/CodeGen/LLVMTargetMachine.cpp +++ b/lib/CodeGen/LLVMTargetMachine.cpp @@ -39,8 +39,6 @@ static cl::opt PrintEmittedAsm("print-emitted-asm", cl::Hidden, cl::desc("Dump emitter generated instructions as assembly")); static cl::opt PrintGCInfo("print-gc", cl::Hidden, cl::desc("Dump garbage collector data")); -static cl::opt HoistConstants("hoist-constants", cl::Hidden, - cl::desc("Hoist constants out of loops")); static cl::opt VerifyMachineCode("verify-machineinstrs", cl::Hidden, cl::desc("Verify generated machine code"), cl::init(getenv("LLVM_VERIFY_MACHINEINSTRS")!=NULL)); @@ -255,11 +253,8 @@ bool LLVMTargetMachine::addCommonCodeGenPasses(PassManagerBase &PM, // Make sure that no unreachable blocks are instruction selected. PM.add(createUnreachableBlockEliminationPass()); - if (OptLevel != CodeGenOpt::None) { - if (HoistConstants) - PM.add(createCodeGenLICMPass()); + if (OptLevel != CodeGenOpt::None) PM.add(createCodeGenPreparePass(getTargetLowering())); - } PM.add(createStackProtectorPass(getTargetLowering())); diff --git a/lib/Transforms/Scalar/CMakeLists.txt b/lib/Transforms/Scalar/CMakeLists.txt index 7d95b90e90a..af6fea707d5 100644 --- a/lib/Transforms/Scalar/CMakeLists.txt +++ b/lib/Transforms/Scalar/CMakeLists.txt @@ -2,7 +2,6 @@ add_llvm_library(LLVMScalarOpts ABCD.cpp ADCE.cpp BasicBlockPlacement.cpp - CodeGenLICM.cpp CodeGenPrepare.cpp CondPropagate.cpp ConstantProp.cpp diff --git a/lib/Transforms/Scalar/CodeGenLICM.cpp b/lib/Transforms/Scalar/CodeGenLICM.cpp deleted file mode 100644 index 10f950e135d..00000000000 --- a/lib/Transforms/Scalar/CodeGenLICM.cpp +++ /dev/null @@ -1,112 +0,0 @@ -//===- CodeGenLICM.cpp - LICM a function for code generation --------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This function performs late LICM, hoisting constants out of loops that -// are not valid immediates. It should not be followed by instcombine, -// because instcombine would quickly stuff the constants back into the loop. -// -//===----------------------------------------------------------------------===// - -#define DEBUG_TYPE "codegen-licm" -#include "llvm/Transforms/Scalar.h" -#include "llvm/Constants.h" -#include "llvm/DerivedTypes.h" -#include "llvm/Instructions.h" -#include "llvm/IntrinsicInst.h" -#include "llvm/LLVMContext.h" -#include "llvm/Analysis/LoopPass.h" -#include "llvm/Analysis/AliasAnalysis.h" -#include "llvm/ADT/DenseMap.h" -using namespace llvm; - -namespace { - class CodeGenLICM : public LoopPass { - virtual bool runOnLoop(Loop *L, LPPassManager &LPM); - virtual void getAnalysisUsage(AnalysisUsage &AU) const; - public: - static char ID; // Pass identification, replacement for typeid - explicit CodeGenLICM() : LoopPass(&ID) {} - }; -} - -char CodeGenLICM::ID = 0; -static RegisterPass X("codegen-licm", - "hoist constants out of loops"); - -Pass *llvm::createCodeGenLICMPass() { - return new CodeGenLICM(); -} - -bool CodeGenLICM::runOnLoop(Loop *L, LPPassManager &) { - bool Changed = false; - - // Only visit outermost loops. - if (L->getParentLoop()) return Changed; - - Instruction *PreheaderTerm = L->getLoopPreheader()->getTerminator(); - DenseMap HoistedConstants; - - for (Loop::block_iterator I = L->block_begin(), E = L->block_end(); - I != E; ++I) { - BasicBlock *BB = *I; - for (BasicBlock::iterator BBI = BB->begin(), BBE = BB->end(); - BBI != BBE; ++BBI) { - Instruction *I = BBI; - // TODO: For now, skip all intrinsic instructions, because some of them - // can require their operands to be constants, and we don't want to - // break that. - if (isa(I)) - continue; - // LLVM represents fneg as -0.0-x; don't hoist the -0.0 out. - if (BinaryOperator::isFNeg(I) || - BinaryOperator::isNeg(I) || - BinaryOperator::isNot(I)) - continue; - for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) { - // Don't hoist out switch case constants. - if (isa(I) && i == 1) - break; - // Don't hoist out shuffle masks. - if (isa(I) && i == 2) - break; - Value *Op = I->getOperand(i); - Constant *C = dyn_cast(Op); - if (!C) continue; - // TODO: Ask the target which constants are legal. This would allow - // us to add support for hoisting ConstantInts and GlobalValues too. - if (isa(C) || - isa(C) || - isa(C)) { - BitCastInst *&BC = HoistedConstants[C]; - if (!BC) - BC = new BitCastInst(C, C->getType(), "hoist", PreheaderTerm); - I->setOperand(i, BC); - Changed = true; - } - } - } - } - - return Changed; -} - -void CodeGenLICM::getAnalysisUsage(AnalysisUsage &AU) const { - // This pass preserves just about everything. List some popular things here. - AU.setPreservesCFG(); - AU.addPreservedID(LoopSimplifyID); - AU.addPreserved(); - AU.addPreserved(); - AU.addPreserved("scalar-evolution"); - AU.addPreserved("iv-users"); - AU.addPreserved("lda"); - AU.addPreserved("live-values"); - - // Hoisting requires a loop preheader. - AU.addRequiredID(LoopSimplifyID); -}