13 Commits

Author SHA1 Message Date
long.chen
dc4786b487
[mlir][affine] remove divide zero check when simplifer affineMap (#64622) (#68519)
When performing constant folding on the affineApplyOp, there is a
division of 0 in the affine map.
[related issue](https://github.com/llvm/llvm-project/issues/64622)

---------

Co-authored-by: Javier Setoain <jsetoain@users.noreply.github.com>
2023-11-19 02:14:53 +08:00
Uday Bondhugula
c79ffb02bb
Generalize affine fusion to work at all depths and inside other region-holding ops (#72288)
Generalize affine fusion to work at any inner depth; fusing loops inside
other
affine.for or even inside scf.for or scf.while nests. Apply in post
order on
all affine nests on the pass' top-level operation.

Fix MDG init for blocks inside other affine nests.

Relax unnecessary requirement for unique vars during merge and align of
FlatLinearValueConstraints. There are several cases where
FlatLinearValueConstraints need to have duplicate Values for the
dimensions:
for eg. in dependence relation systems with source and destination
accesses
could have common loop IVs. `mergeAndAlign` can be done even in the
presence
of Values reappearing by simply aligning from left to right in that
order.

While at this, drop outdated comments; improve some debug messages.
2023-11-16 08:52:12 +05:30
long.chen
1609f1c2a5
[mlir][affine][nfc] cleanup deprecated T.cast style functions (#71269)
detail see the docment: https://mlir.llvm.org/deprecation/

Not all changes are made manually, most of them are made through a clang
tool I wrote https://github.com/lipracer/cpp-refactor.
2023-11-14 13:01:19 +08:00
Kazu Hirata
3f0bddb56a Use llvm::find (NFC) 2023-09-23 16:27:02 -07:00
Abhinav271828
c1b997464b
[MLIR][Presburger] Template Matrix to allow MPInt and Fraction; use IntMatrix for integer matrices (#66897)
Matrix has been templated to Matrix (for MPInt and Fraction) with
explicit instantiation for both these types.
IntMatrix, inheriting from Matrix<MPInt>, has been created to allow for
integer-only methods.
makeMatrix has been duplicated to makeIntMatrix and makeFracMatrix.

This was already landed previously but was reverted in
98c994c8e22d7f38cc04f56ee5cdeb337734414d due to build failure. This
fixes the failure.
2023-09-20 14:29:33 +01:00
Arjun P
98c994c8e2 Revert "[MLIR][Presburger] Template Matrix to allow MPInt and Fraction (#65272)"
This reverts commit efca035c6d28542ad6374cd8bf17ae7c72407ead.

Reverting due to windows build bot failure:
https://lab.llvm.org/buildbot/#/builders/13/builds/40242/steps/6/logs/stdio
2023-09-18 19:06:32 +01:00
Abhinav271828
efca035c6d
[MLIR][Presburger] Template Matrix to allow MPInt and Fraction (#65272)
The method implementations remain in the .cpp file; explicit instantiations have been added for these two types. 
makeMatrix has been duplicated to makeIntMatrix and makeFracMatrix.
2023-09-18 22:52:22 +05:30
Alexander Belyaev
2e52b093cf [mlir] Remove dead code in Analysis/FlatLinearValueConstraints.
Differential Revision: https://reviews.llvm.org/D154830
2023-07-19 08:19:53 +02:00
Vinayaka Bandishti
c45c96250b [Affine-fusion] Fix a bug in mod detection
Fix a bug in detecting unknown ids as mods of known ids that was
preventing certain fusions.

While at this, fix the function signature of `detectAsMod` function to
have output as the last argument.

Reviewed By: bondhugula

Differential Revision: https://reviews.llvm.org/D152055
2023-06-05 10:47:48 +05:30
Kazu Hirata
1b2247d932 [mlir] Replace None with std::nullopt in comments (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2023-04-26 23:29:02 -07:00
Matthias Springer
7e5d300d0a [mlir][Analysis] Fix assertion in FlatLinearConstraints
Differential Revision: https://reviews.llvm.org/D146869
2023-03-25 12:54:17 +01:00
Matthias Springer
47bff1cc46 [mlir][Analysis][NFC] Make BoundType a top-level enum
`BoundType` is no longer a nested member of `IntegerRelation` but a top-level enum in the `presburger` namespace.

This allows `BoundType` to be predeclared in header files. Nested members cannot be predeclared.

Differential Revision: https://reviews.llvm.org/D146210
2023-03-23 09:46:21 +01:00
Matthias Springer
5b0055a4ae [mlir][Analysis][NFC] Split FlatAffineValueConstraints into multiple classes
The new class hierarchy is as follows:

* `IntegerRelation` (no change)
* `IntegerPolyhedron` (no change)
* `FlatLinearConstraints`: provides an AffineExpr-based API
* `FlatLinearValueConstraints`: stores an additional mapping of non-local vars to SSA values
* `FlatAffineValueConstraints`: provides additional helper functions for Affine dialect ops
* `FlatAffineRelation` (no change)

`FlatConstraints` and `FlatValueConstraints` are moved from `MLIRAffineAnalysis` to `MLIRAnalysis` and can be used without depending on the Affine dialect.

This change is in preparation of D145681, which adds an MLIR interface that depends on `FlatConstraints` (and cannot depend on the Affine dialect or any other dialect).

Differential Revision: https://reviews.llvm.org/D146201
2023-03-23 09:38:12 +01:00