This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][Presburger] Implement domain and range restriction for PresburgerRelation
ClosedPublic

Authored by iambrj on Jul 9 2023, 2:18 PM.

Details

Summary

This patch implements domain and range restriction for PresburgerRelation

Diff Detail

Event Timeline

iambrj created this revision.Jul 9 2023, 2:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 9 2023, 2:18 PM
iambrj requested review of this revision.Jul 9 2023, 2:18 PM
iambrj updated this revision to Diff 538449.Jul 9 2023, 2:21 PM

Fix grammar

iambrj updated this revision to Diff 538450.Jul 9 2023, 2:24 PM

Grammar again

Groverkss added inline comments.Jul 10 2023, 7:23 AM
mlir/include/mlir/Analysis/Presburger/PresburgerRelation.h
88–103

These methods should return PresburgerRelation. Methods in PresburgerRelation return a new object unless they have a "inPlace" suffix.

mlir/lib/Analysis/Presburger/PresburgerRelation.cpp
127–157

I would try to reuse PresburgerRelation::intersect as much as possible. We are implementing simplifications in core methods like intersect and it makes it harder to keep track of these things otherwise.

iambrj added inline comments.Jul 11 2023, 12:32 PM
mlir/include/mlir/Analysis/Presburger/PresburgerRelation.h
88–103

Right. What is the rule of thumb for suffixing "inPlace"? For example, inverse, compose, and applyDomain do not have "inPlace" suffixed, even though they mutate the object and do not return a new object.

mlir/lib/Analysis/Presburger/PresburgerRelation.cpp
127–157

The way I can see to implement intersectRange with intersect is to convert the passed PresburgerSet into a PresburgerRelation, insert domain variables to the converted PresburgerRelation to make it intersectable with this, and then call intersect. Would the above be a good way to do it? Do you have any suggestions on other ways to do it?

Groverkss added inline comments.Jul 12 2023, 6:47 AM
mlir/include/mlir/Analysis/Presburger/PresburgerRelation.h
88–103

I think we try to do our best in suffixing things. For older methods, we might have to fix this naming later. But for now, since intersect returns a PresburgerRelation, it's best if intersectDomain/Range also does the same.

mlir/lib/Analysis/Presburger/PresburgerRelation.cpp
127–157

I think that sounds like a good way to me.

iambrj updated this revision to Diff 539667.Jul 12 2023, 12:07 PM

Address comments

iambrj updated this revision to Diff 539669.Jul 12 2023, 12:12 PM

Remove unused include

iambrj marked 2 inline comments as done.Jul 12 2023, 12:13 PM
Groverkss added inline comments.Jul 15 2023, 1:16 PM
mlir/include/mlir/Analysis/Presburger/PresburgerRelation.h
88
91–93

I think using the same set is confusing. I prefer the same documentation as IntegerRelation::intersectRange

/// Formally, let the relation `this` be R: A -> B and poly is C, then this
/// operation modifies R to be A -> (B intersection C).
96
99–101

Similarly for this:

/// Formally, let the relation `this` be R: A -> B and poly is C, then this
/// operation modifies R to be (A intersection C) -> B.
mlir/lib/Analysis/Presburger/PresburgerRelation.cpp
35–37

Braces can be removed.

iambrj added inline comments.Jul 15 2023, 8:49 PM
mlir/include/mlir/Analysis/Presburger/PresburgerRelation.h
91–93

Sure, do you suggest the passed PresburgerSet's name be changed to poly as well?

Groverkss added inline comments.Jul 17 2023, 5:46 AM
mlir/include/mlir/Analysis/Presburger/PresburgerRelation.h
91–93

You can just change "poly" to "set" in the documentation. But if you prefer it the other way, you can do that too. As long as the documentation makes sense, it's fine.

iambrj updated this revision to Diff 540978.Jul 17 2023, 5:50 AM

Address comments

iambrj marked 3 inline comments as done.Jul 17 2023, 5:52 AM
This revision is now accepted and ready to land.Jul 17 2023, 6:02 AM