- Detect "c_1 * expr + c_2 * expr" as (c_1 + c_2) * expr
- subsumes things like 'expr - expr' and "expr * -1 + expr" as 0.
- add default null init ctor for AffineConstantExpr
Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Paths
| Differential D76233
Affine expr simplification for add of const multiple of same expression ClosedPublic Authored by bondhugula on Mar 16 2020, 8:53 AM.
Details Summary
Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Diff Detail
Event TimelineComment Actions LGTM See: https://github.com/llvm/llvm-project/blob/master/mlir/lib/Dialect/SDBM/SDBMExpr.cpp#L31 in case you like something from there to write such expressions more idiomatically and wish to lift it up. This revision is now accepted and ready to land.Mar 16 2020, 11:53 AM Comment Actions
Looks good and useful. You may also want to add the operator '/' for floordiv. This would be in general useful to implement some detection at least from under Analysis/. You could just consider moving it to lib/Analysis/Utils so that it's not a dependence on the SDBM dialect. One use case could have been to simplify (x - x floordiv d) as x mod d, but we have this by construction in lib/IR/AffineExpr.cpp. Also, it may be useful to have a way to constrain an AffineExprMatcher to positive constants for example. But this is all meant for "post construction" matching as opposed to simplifying before / by construction itself, right? Closed by commit rG332f0b3cd484: Affine expr simplification for add of const multiple of same expression (authored by bondhugula). · Explain WhyMar 16 2020, 8:13 PM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 250683 mlir/include/mlir/IR/AffineExpr.h
mlir/lib/IR/AffineExpr.cpp
mlir/test/Dialect/AffineOps/canonicalize.mlir
mlir/test/IR/affine-map.mlir
|
Can you just add = nullptr to the other constructor?