This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][Presburger] IntegerRelation: implement partial rollback support
ClosedPublic

Authored by arjunp on Mar 21 2022, 1:44 PM.

Details

Summary

It is often necessary to "rollback" IntegerRelations to an earlier state. Although providing full rollback support is non-trivial, we really only need to support the case where the only changes made are to append ids or append constraints, and then rollback these additions. This patch adds support to rollback in such situations by recording the number of ids and constraints of each kind and providing support to truncate the IntegerRelation to those counts by removing appended ids and constraints. This already simplifies subtraction a little bit and will also be useful in the implementation of symbolic integer lexmin.

Diff Detail

Event Timeline

arjunp created this revision.Mar 21 2022, 1:44 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 21 2022, 1:44 PM
arjunp requested review of this revision.Mar 21 2022, 1:44 PM

Can you write a patch description with the reasoning for this patch?

arjunp edited the summary of this revision. (Show Details)Mar 23 2022, 4:20 AM
Groverkss added inline comments.Mar 23 2022, 2:22 PM
mlir/include/mlir/Analysis/Presburger/IntegerRelation.h
155

Can we have a better name than Counts? Maybe IntegerRelationState or something more descriptive?

arjunp added inline comments.Mar 23 2022, 3:31 PM
mlir/include/mlir/Analysis/Presburger/IntegerRelation.h
155

I named it counts to make it clear it's not really a proper thing storing the full state. Do you have a better suggestion that also conveys that it's not a proper snapshot?

Groverkss added inline comments.Mar 23 2022, 3:46 PM
mlir/include/mlir/Analysis/Presburger/IntegerRelation.h
155

Maybe CountState? I just find Counts not very descriptive.

arjunp updated this revision to Diff 417786.Mar 23 2022, 4:40 PM

Move truncateIdKind to PresburgerSpace and change Counts -> CountsSnapshot

This revision is now accepted and ready to land.Mar 23 2022, 5:03 PM