This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][Presburger] Attach values only to non-local identifiers in FAVC
ClosedPublic

Authored by Groverkss on May 14 2022, 11:45 AM.

Details

Summary

This patch changes FlatAffineValueConstraints to only allow attaching
values to non-local identifiers.

The reasoning for this change is:

  1. Information attached to local identifiers can be lost since local identifiers can be removed for output size optimizations.
  2. There are no current use cases for attaching values to Local identifiers.
  3. Attaching a value to a local identifier does not make sense since a local identifier represents existential quantification.

This patch also adds some additional asserts to the affected functions.

Diff Detail

Event Timeline

Groverkss created this revision.May 14 2022, 11:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 14 2022, 11:45 AM
Groverkss requested review of this revision.May 14 2022, 11:45 AM
Groverkss edited the summary of this revision. (Show Details)May 14 2022, 1:51 PM
arjunp requested changes to this revision.May 16 2022, 8:01 AM
arjunp added inline comments.
mlir/include/mlir/Dialect/Affine/Analysis/AffineStructures.h
419–421

These aren't equivalent. I agree that the start <= end assert is required, though. But is the ability to pass any value when end == start not used? I figure we could preserve that ability as well

456–458

Simliarly, can we just early exit for start >= end?

459
mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
1354–1358

It seems bad to silently "lose" the Value here. Should we maybe assert-fail if this happens? Is this used?

This revision now requires changes to proceed.May 16 2022, 8:01 AM
Groverkss updated this revision to Diff 429922.May 16 2022, 7:42 PM
Groverkss marked 2 inline comments as done.
  • Address Arjun's comments
Groverkss marked 2 inline comments as done.May 16 2022, 7:42 PM
Groverkss added inline comments.
mlir/include/mlir/Dialect/Affine/Analysis/AffineStructures.h
419–421

I think the new assert covers all existing cases and adds another check that start <= end.

Could you point to a case that would pass before (and be a valid range, i.e. start <= end) but not now? I do not see one.

456–458

That wouldn't make sense to me. If start >= end and values.size() has to have the same size as the range, I don't see what the user would pass. I would prefer having this assertion to prevent bugs.

mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
1354–1358

We swap local ids with dim/sym ids when projecting a dim/sym to a local variable. So, it is used.

arjunp accepted this revision.May 17 2022, 3:27 AM
arjunp added inline comments.
mlir/include/mlir/Dialect/Affine/Analysis/AffineStructures.h
419–421

Previously start == end would do nothing and work even if start, end are too big. Just mention in the description that some additional asserts were added if we are adding additional constraints

This revision is now accepted and ready to land.May 17 2022, 3:27 AM
Groverkss edited the summary of this revision. (Show Details)May 17 2022, 3:35 AM
Groverkss marked 2 inline comments as done.
Groverkss retitled this revision from [MLIR][Presburger] Only attach values to non-local identifiers in FAVC to [MLIR][Presburger] Attach values only to non-local identifiers in FAVC.May 17 2022, 5:42 AM
bondhugula accepted this revision.May 17 2022, 6:55 PM

LGTM - thanks. There aren't indeed any use cases to attach Values to local identifiers. Some minor comments.

This patch changes FlatAffineValueConstraints to only allow attaching non-local identifiers to it.

The first line of the commit summary has a typo somewhere.

mlir/include/mlir/Dialect/Affine/Analysis/AffineStructures.h
36

It looks like we are missing updates to the values field in the class to document they are only for dims and symbols?

408

Nit: assertion messages like these aren't typically ended with a full stop.

446

Update doc comment to mention it's only for dim and symbol identifiers.

mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
306

Update doc comment on insertId?

Groverkss updated this revision to Diff 430229.May 17 2022, 8:25 PM
Groverkss marked 4 inline comments as done.
  • Address Uday's comments
Groverkss edited the summary of this revision. (Show Details)May 17 2022, 8:42 PM