[LLVMdev] [polly] pass ordering

Sebastian Pop
Wed, 17 Apr 2013 15:53:06 -0000

Hi,

polly is run very early and schedules the following passes before it runs:

/// @brief Schedule a set of canonicalization passes to prepare for Polly
///
/// The set of optimization passes was partially taken/copied from the
/// set of default optimization passes in LLVM. It is used to bring the code
/// into a canonical form that simplifies the analysis and optimization passes
/// of Polly. The set of optimization passes scheduled here is probably not yet
/// optimal. TODO: Optimize the set of canonicalization passes.
static void registerCanonicalicationPasses(llvm::PassManagerBase &PM) {
  PM.add(llvm::createPromoteMemoryToRegisterPass());
  PM.add(llvm::createInstructionCombiningPass());
  PM.add(llvm::createCFGSimplificationPass());
  PM.add(llvm::createTailCallEliminationPass());
  PM.add(llvm::createCFGSimplificationPass());
  PM.add(llvm::createReassociatePass());
  PM.add(llvm::createLoopRotatePass());
  PM.add(llvm::createInstructionCombiningPass());

  if (!SCEVCodegen)
    PM.add(polly::createIndVarSimplifyPass());

  PM.add(polly::createCodePreparationPass());
  PM.add(polly::createRegionSimplifyPass());


Sergei was saying that on some benchmarks PromoteMemoryToRegister was causing
performance regressions when it is run with and without Polly and scheduled that
early.  Another remark is that these passes apply to all the functions,
transforming them without considering whether they contain loops or whether
Polly could improve anything.

That brings the question: why do we run Polly that early?  Could we move Polly
down after all these passes have been scheduled by LLVM's scalar optimizer?

Thanks,
Sebastian
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation