This is an archive of the discontinued LLVM Phabricator instance.

[MLIR] Simplify Semi-affine expressions by rule based matching and replacing "expr - q * (expr floordiv q)" with "expr mod q" expression.
ClosedPublic

Authored by arnab-oss on Nov 1 2021, 11:23 PM.

Details

Summary

Add rule based matching for detecting and transforming "expr - q * (expr floordiv q)"
to "expr mod q", where q is a symbolic exxpression, in simplifyAdd function.

Diff Detail

Event Timeline

arnab-oss created this revision.Nov 1 2021, 11:23 PM
arnab-oss requested review of this revision.Nov 1 2021, 11:23 PM
arnab-oss retitled this revision from [MLIR] Simplify Semi-affine expressions. to [MLIR] Simplify Semi-affine expressions by rule based matching and replacing with mod expression..Nov 1 2021, 11:24 PM
arnab-oss retitled this revision from [MLIR] Simplify Semi-affine expressions by rule based matching and replacing with mod expression. to [MLIR] Simplify Semi-affine expressions by rule based matching and replacing "expr - q * (expr floordiv q)" with "expr mod q" expression..Nov 1 2021, 11:29 PM
bondhugula added inline comments.Nov 15 2021, 8:24 AM
mlir/lib/IR/AffineExpr.cpp
620

You don't need the extra llrhsBinOpExpr on the second disjunct.

mlir/test/Dialect/Affine/simplify-affine-structures.mlir
487

Sorted order here -- move this up.

492

CHECK-LABEL here while at this.

bondhugula accepted this revision.Nov 16 2021, 2:17 AM
bondhugula added inline comments.
mlir/lib/IR/AffineExpr.cpp
608

-> Check if lrhsBin... is of the form ...

mlir/test/Dialect/Affine/simplify-affine-structures.mlir
493

Nit: use underscore between semi and affine.

This revision is now accepted and ready to land.Nov 16 2021, 2:17 AM
arnab-oss updated this revision to Diff 388464.Nov 19 2021, 4:40 AM

Added test cases.

arnab-oss updated this revision to Diff 388466.Nov 19 2021, 4:51 AM
arnab-oss marked 5 inline comments as done.

Addressed all comments by @bondhugula

ping @dcaballe and @springerm , can you please take a look and review this? This is a continuation of semi affine expression simplification PR.

dcaballe accepted this revision.Nov 19 2021, 2:18 PM

LGTM, thanks!

bondhugula accepted this revision.Nov 20 2021, 7:34 AM