This is an archive of the discontinued LLVM Phabricator instance.

Pin -loop-reduce to legacy PM
ClosedPublic

Authored by aeubanks on Dec 7 2020, 3:40 PM.

Details

Summary

LSR currently only runs in the codegen pass manager.
There are a couple issues with LSR and the NPM.

  1. Lots of tests assume that LCSSA isn't run before LSR. This breaks a

bunch of tests' expected output. This is fixable with some time put in.

  1. LSR doesn't preserve LCSSA. See

llvm/test/Analysis/MemorySSA/update-remove-deadblocks.ll. LSR's use of
SCEVExpander is the only use of SCEVExpander where the PreserveLCSSA option is
off. Turning it on causes some code sinking out of loops to fail due to
SCEVExpander's inability to handle the newly created trivial PHI nodes in the
broken critical edge (I was looking at
llvm/test/Transforms/LoopStrengthReduce/X86/2011-11-29-postincphi.ll).
I also tried simply just calling formLCSSA() at the end of LSR, but the extra
PHI nodes cause regressions in codegen tests.

We'll delay figuring these issues out until later.

This causes the number of check-llvm failures with -enable-new-pm true
by default to go from 60 to 29.

Diff Detail

Event Timeline

aeubanks created this revision.Dec 7 2020, 3:40 PM
aeubanks requested review of this revision.Dec 7 2020, 3:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 7 2020, 3:40 PM
rnk added a comment.Dec 7 2020, 3:51 PM

I'm in favor of this, but I'd like to get a second opinion from the other reviewers.

asbirlea accepted this revision.Dec 8 2020, 1:09 PM

Discussed this offline, and proposed this solution to make progress and resolve the failing tests.
This does need exploring further though as:

  1. the behavior of current LSR will no longer be tested in the new pass manager, due to LCSSA being run as a canonicalization pass.
  2. adding it to a loop pass manager in the npm will be problematic, because it doesn't preserve LCSSA.
This revision is now accepted and ready to land.Dec 8 2020, 1:09 PM

Currently LSR is not tested with the NPM in any circumstance.
There are no tests with -passes=loop-reduce, and LSR is only used in the codegen pass manager, so even with -DEXPERIMENTAL_NEW_PASS_MANAGER=ON, it's never in a NPM context.

Currently LSR is not tested with the NPM in any circumstance.
There are no tests with -passes=loop-reduce, and LSR is only used in the codegen pass manager, so even with -DEXPERIMENTAL_NEW_PASS_MANAGER=ON, it's never in a NPM context.

Exactly! But it's ported. So someone could add it to a pipeline anytime and chaos would ensue, that's what I meant :-). There may be out-of-tree usages or tests that are broken.

Currently LSR is not tested with the NPM in any circumstance.
There are no tests with -passes=loop-reduce, and LSR is only used in the codegen pass manager, so even with -DEXPERIMENTAL_NEW_PASS_MANAGER=ON, it's never in a NPM context.

Exactly! But it's ported. So someone could add it to a pipeline anytime and chaos would ensue, that's what I meant :-). There may be out-of-tree usages or tests that are broken.

Oh I see. Weird that it's ported but there are no tests for it.

Never mind I lied, there's one test ivchain.ll (plus an optnone test)

This revision was landed with ongoing or failed builds.Dec 8 2020, 1:48 PM
This revision was automatically updated to reflect the committed changes.