This is an archive of the discontinued LLVM Phabricator instance.

[LICM][NFC] Don't preserve DT and loop analyzes separately
ClosedPublic

Authored by mkazantsev on Feb 27 2023, 3:15 AM.

Details

Summary

This is already implied by getLoopPassPreservedAnalyses.

Diff Detail

Event Timeline

mkazantsev created this revision.Feb 27 2023, 3:15 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 27 2023, 3:15 AM
mkazantsev requested review of this revision.Feb 27 2023, 3:15 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 27 2023, 3:15 AM
nikic requested changes to this revision.Feb 27 2023, 3:22 AM

These area already part of getLoopPassPreservedAnalyses().

This revision now requires changes to proceed.Feb 27 2023, 3:22 AM

Is it? I was reading LICM code and it's like

PreservedAnalyses LICMPass::run(Loop &L, LoopAnalysisManager &AM,
                                LoopStandardAnalysisResults &AR, LPMUpdater &) {
  if (!AR.MSSA)
    report_fatal_error("LICM requires MemorySSA (loop-mssa)",
                       /*GenCrashDiag*/false);

  // For the new PM, we also can't use OptimizationRemarkEmitter as an analysis
  // pass.  Function analyses need to be preserved across loop transformations
  // but ORE cannot be preserved (see comment before the pass definition).
  OptimizationRemarkEmitter ORE(L.getHeader()->getParent());

  LoopInvariantCodeMotion LICM(Opts.MssaOptCap, Opts.MssaNoAccForPromotionCap,
                               Opts.AllowSpeculation);
  if (!LICM.runOnLoop(&L, &AR.AA, &AR.LI, &AR.DT, &AR.AC, &AR.TLI, &AR.TTI,
                      &AR.SE, AR.MSSA, &ORE))
    return PreservedAnalyses::all();

  auto PA = getLoopPassPreservedAnalyses();

  PA.preserve<DominatorTreeAnalysis>();
  PA.preserve<LoopAnalysis>();
  PA.preserve<MemorySSAAnalysis>();

  return PA;
}

Should we then remove it from there?

Is it? I was reading LICM code and it's like

PreservedAnalyses LICMPass::run(Loop &L, LoopAnalysisManager &AM,
                                LoopStandardAnalysisResults &AR, LPMUpdater &) {
  if (!AR.MSSA)
    report_fatal_error("LICM requires MemorySSA (loop-mssa)",
                       /*GenCrashDiag*/false);

  // For the new PM, we also can't use OptimizationRemarkEmitter as an analysis
  // pass.  Function analyses need to be preserved across loop transformations
  // but ORE cannot be preserved (see comment before the pass definition).
  OptimizationRemarkEmitter ORE(L.getHeader()->getParent());

  LoopInvariantCodeMotion LICM(Opts.MssaOptCap, Opts.MssaNoAccForPromotionCap,
                               Opts.AllowSpeculation);
  if (!LICM.runOnLoop(&L, &AR.AA, &AR.LI, &AR.DT, &AR.AC, &AR.TLI, &AR.TTI,
                      &AR.SE, AR.MSSA, &ORE))
    return PreservedAnalyses::all();

  auto PA = getLoopPassPreservedAnalyses();

  PA.preserve<DominatorTreeAnalysis>();
  PA.preserve<LoopAnalysis>();
  PA.preserve<MemorySSAAnalysis>();

  return PA;
}

Should we then remove it from there?

I think yes.

PreservedAnalyses llvm::getLoopPassPreservedAnalyses() {
  PreservedAnalyses PA;
  PA.preserve<DominatorTreeAnalysis>();
  PA.preserve<LoopAnalysis>();
  PA.preserve<LoopAnalysisManagerFunctionProxy>();
  PA.preserve<ScalarEvolutionAnalysis>();
  return PA;
}
mkazantsev abandoned this revision.Feb 27 2023, 10:45 PM

Okay :)

mkazantsev reclaimed this revision.Feb 27 2023, 10:46 PM
This revision now requires changes to proceed.Feb 27 2023, 10:46 PM
mkazantsev retitled this revision from [LoopPredication][NFC] Preserve DT and loop analyzes to [LICM][NFC] Don't preserve DT and loop analyzes separately.
mkazantsev edited the summary of this revision. (Show Details)
skatkov accepted this revision.Feb 27 2023, 10:52 PM
nikic accepted this revision.Feb 28 2023, 12:43 AM

LGTM

This revision is now accepted and ready to land.Feb 28 2023, 12:43 AM
This revision was landed with ongoing or failed builds.Feb 28 2023, 2:03 AM
This revision was automatically updated to reflect the committed changes.