This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][Presburger] subtract: fix bug when an input set has duplicate divisions
ClosedPublic

Authored by arjunp on Mar 31 2022, 8:08 AM.

Details

Summary

Previously, when an input set had a duplicate division, the duplicates might
be removed by a call to mergeLocalIds due to being detected as being duplicate
for the first time. The subtraction implementation cannot handle existing
locals being removed, so this would lead to unexpected behaviour. Resolve this
by removing all the duplicates up front.

Diff Detail

Event Timeline

arjunp created this revision.Mar 31 2022, 8:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 31 2022, 8:08 AM
arjunp requested review of this revision.Mar 31 2022, 8:08 AM
Groverkss retitled this revision from [MLIR][Presburger] subtract: fix bug when an input set has duplicate divivions to [MLIR][Presburger] subtract: fix bug when an input set has duplicate divisions.Mar 31 2022, 11:41 AM
Groverkss accepted this revision.Apr 1 2022, 3:45 AM

LGTM.

mlir/lib/Analysis/Presburger/IntegerRelation.cpp
1099–1103

We should later make it so that the merge function returns false if the divs belong to the same relation, such that it does not remove duplicate divisions. But for now, it's fine.

This revision is now accepted and ready to land.Apr 1 2022, 3:45 AM
arjunp added inline comments.Apr 1 2022, 3:51 AM
mlir/lib/Analysis/Presburger/IntegerRelation.cpp
1099–1103

We'll have to think what that even means. Let's say the same div occurs twice in each set. What is the guarantee on the number of occurrences in the final set? Will it be the max of the number of occurrences in each set? Seems weird. I think it's better to just have the users remove duplicates upfront if they don't want this to happen. Anyway, we should eventually just make addFloorDiv not add duplicates maybe, at least by default.

1099–1103

(Not a perfect solution but that might avoid this problem entirely in many cases.)

This revision was landed with ongoing or failed builds.Apr 1 2022, 4:38 AM
This revision was automatically updated to reflect the committed changes.