[PATCH] D79502: [mlir] Support partial folding of affine.min/max
Andy Davis via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 6 13:00:42 PDT 2020
andydavis1 accepted this revision.
andydavis1 added a comment.
This revision is now accepted and ready to land.
Thanks Alex!
================
Comment at: mlir/lib/Dialect/Affine/IR/AffineOps.cpp:2102
+/// Populate "results" with constant results of "map". If some of the "map"
+/// results are not constant affine expressions, resturn failure.
+static LogicalResult extractIntegerResults(AffineMap map,
----------------
"returns failure"
================
Comment at: mlir/lib/Dialect/Affine/IR/AffineOps.cpp:2122
// Fold the affine map.
// TODO(andydavis, ntv) Fold more cases: partial static information,
// min(some_affine, some_affine + constant, ...).
----------------
Can you remove this TODO now?
================
Comment at: mlir/lib/Dialect/Affine/IR/AffineOps.cpp:2162
+ // If some of the map results are not constant, try changing the map in-place.
+ SmallVector<int64_t, 2> results;
+ if (failed(extractIntegerResults(foldedMap, results))) {
----------------
Seems like this block of code could be shared with AffineMin::Fold
================
Comment at: mlir/lib/IR/AffineMap.cpp:266
+
for (auto expr : getResults()) {
+ // If did not fold to a constant, keep the original expression.
----------------
Could this function also return if all results were constants? Would this allow you to avoid calling extractIntegerResults in affine.min/max.fold above?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D79502/new/
https://reviews.llvm.org/D79502
More information about the llvm-commits
mailing list