This is an archive of the discontinued LLVM Phabricator instance.

[mlir][scf] Support simple symbolic expression when simplify loops
ClosedPublic

Authored by Peiming on Sep 19 2022, 11:42 AM.

Diff Detail

Event Timeline

Peiming created this revision.Sep 19 2022, 11:42 AM
Peiming requested review of this revision.Sep 19 2022, 11:42 AM
Peiming added inline comments.
mlir/lib/Dialect/SCF/IR/SCF.cpp
738

Or should we use ()[s0]->(s0) for id map?

LGTM overall, I let Nicolas/Thomas comment more.
Also, perhaps add a CHECK test?

(since my example is not submitted yet)

mlir/lib/Dialect/SCF/IR/SCF.cpp
11

Does this new dep require some bazel changes?

738

I let Thomas comment on that.

747

maybe put this whole block in a computeDiff() method that returns optional difference?
that makes the individual methods a bit easier to read?

Peiming updated this revision to Diff 461293.Sep 19 2022, 12:05 PM
Peiming marked an inline comment as not done.

updating bazel file

mlir/lib/Dialect/SCF/IR/SCF.cpp
11

Yeah, you are right.

Added the bazel changes

Peiming updated this revision to Diff 461299.Sep 19 2022, 12:17 PM

address comment from Aart.

Peiming updated this revision to Diff 461302.Sep 19 2022, 12:19 PM

add comments.

aartbik added inline comments.Sep 19 2022, 12:25 PM
mlir/lib/Dialect/SCF/IR/SCF.cpp
747

Yeah, love the new format! Thanks!

please add a test

mlir/lib/Dialect/SCF/IR/SCF.cpp
738

I think this is fine.

751

nit: use dyn_cast instead of isa + cast

Peiming updated this revision to Diff 461337.Sep 19 2022, 1:20 PM

add a test case.

aartbik added inline comments.Sep 19 2022, 1:24 PM
mlir/test/Dialect/SCF/canonicalize.mlir
734 ↗(On Diff #461337)

not that c2 x c2 always folds into 4

I think the test would be a bit better if you use

%7 = arith.mulf %arg2, %c2 : f32

and test for 2xarg0 in the folded consume

ThomasRaoux added inline comments.Sep 19 2022, 1:27 PM
utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
2681

I believe you need the matching change in CMakeLists.txt

Peiming updated this revision to Diff 461342.Sep 19 2022, 1:31 PM

update test case

Peiming updated this revision to Diff 461346.Sep 19 2022, 1:39 PM
Peiming marked an inline comment as done.

add dependency in CMake file

Peiming marked an inline comment as done.Sep 19 2022, 1:39 PM
Peiming added inline comments.
utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
2681

Good catch!

Peiming updated this revision to Diff 461349.Sep 19 2022, 1:42 PM
Peiming marked an inline comment as done.

remove unused parameter in test case

Peiming marked 5 inline comments as done.Sep 19 2022, 1:47 PM
aartbik added a comment.EditedSep 19 2022, 2:05 PM
This comment has been deleted.
mlir/test/Dialect/SCF/canonicalize.mlir
737 ↗(On Diff #461349)

%init -> %arg2 so that we see %arg2 -> %arg1 change?

Peiming updated this revision to Diff 461355.Sep 19 2022, 2:09 PM

update test case

Peiming marked an inline comment as done.Sep 19 2022, 2:11 PM
aartbik accepted this revision.Sep 19 2022, 2:16 PM
This revision is now accepted and ready to land.Sep 19 2022, 2:16 PM
ThomasRaoux accepted this revision.Sep 19 2022, 2:37 PM
Peiming updated this revision to Diff 461381.Sep 19 2022, 2:49 PM

rebase against main

This revision was landed with ongoing or failed builds.Sep 19 2022, 2:50 PM
This revision was automatically updated to reflect the committed changes.
ftynse added a subscriber: ftynse.Sep 19 2022, 11:29 PM

Adding a dependency from SCF on Affine sounds like a quite unfortunate layering inversion...

Adding a dependency from SCF on Affine sounds like a quite unfortunate layering inversion...

Do you want the commit to be reverted?

Adding a dependency from SCF on Affine sounds like a quite unfortunate layering inversion...

See https://reviews.llvm.org/D134291