This is an archive of the discontinued LLVM Phabricator instance.

[mli][Linalg] Add a hoistViewAllocOps helper function
ClosedPublic

Authored by nicolasvasilache on Jun 4 2020, 5:37 AM.

Details

Summary

This revision adds a helper function to hoist alloc/dealloc pairs and
alloca op out of immediately enclosing scf::ForOp if both conditions are true:

  1. all operands are defined outside the loop.
  2. all uses are ViewLikeOp or DeallocOp.

This is now considered Linalg-specific and will be generalized on a per-need basis.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptJun 4 2020, 5:37 AM
ftynse accepted this revision.Jun 4 2020, 5:59 AM

LGTM module some comments

mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
520

Spurious whitespace change

mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp
34

Is this loop necessary? It doesn't look like hoisiting only the alloc can put operands of allocs out of the loop.

48

This seems to contradict the code, which fails and returns from the function if any operand is _not_ defined outside of the loop

58

Nit: assert there's one result?

66

Copy-pasta

mlir/test/Dialect/Linalg/hoisting.mlir
24

These are a awkward to read IMO

This revision is now accepted and ready to land.Jun 4 2020, 5:59 AM
nicolasvasilache marked 6 inline comments as done.Jun 4 2020, 3:54 PM

Address review

This revision was automatically updated to reflect the committed changes.