summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUday Bondhugula <udayb@iisc.ac.in>2019-11-07 10:26:51 -0800
committerA. Unique TensorFlower <gardener@tensorflow.org>2019-11-07 10:27:27 -0800
commiteb47d5ee66e2e3dc4d9f2fc7768c41f6b037f3db (patch)
treeea757718c77bb5ff0c49a319f23909ce73f3e4dd
parent8f00b4494d0434eedd8c80917d17d33d395ea65d (diff)
downloadbcm5719-llvm-eb47d5ee66e2e3dc4d9f2fc7768c41f6b037f3db.tar.gz
bcm5719-llvm-eb47d5ee66e2e3dc4d9f2fc7768c41f6b037f3db.zip
Fix asm printer for affine expr
- fixes tensorflow/mlir#201 Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#204 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/204 from bondhugula:printfix 3f8a5b65391f45598258b2735fecaa409fbde848 PiperOrigin-RevId: 279115720
-rw-r--r--mlir/lib/IR/AsmPrinter.cpp5
-rw-r--r--mlir/test/IR/affine-map.mlir6
2 files changed, 10 insertions, 1 deletions
diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp
index 0d0c40cdd1e..43452b2712d 100644
--- a/mlir/lib/IR/AsmPrinter.cpp
+++ b/mlir/lib/IR/AsmPrinter.cpp
@@ -1182,9 +1182,12 @@ void ModulePrinter::printAffineExprInternal(
// Pretty print multiplication with -1.
auto rhsConst = rhsExpr.dyn_cast<AffineConstantExpr>();
- if (rhsConst && rhsConst.getValue() == -1) {
+ if (rhsConst && binOp.getKind() == AffineExprKind::Mul &&
+ rhsConst.getValue() == -1) {
os << "-";
printAffineExprInternal(lhsExpr, BindingStrength::Strong, printValueName);
+ if (enclosingTightness == BindingStrength::Strong)
+ os << ')';
return;
}
diff --git a/mlir/test/IR/affine-map.mlir b/mlir/test/IR/affine-map.mlir
index 914f75cc7e3..ab7647b2d76 100644
--- a/mlir/test/IR/affine-map.mlir
+++ b/mlir/test/IR/affine-map.mlir
@@ -174,6 +174,9 @@
// CHECK: #map{{[0-9]+}} = (d0) -> (d0 - (d0 + 1))
#map53 = (d0) -> (d0 - (d0 + 1))
+// CHECK: #map{{[0-9]+}} = (d0)[s0] -> ((-s0) floordiv 4, d0 floordiv -1)
+#map54 = (d0)[s0] -> (-s0 floordiv 4, d0 floordiv -1)
+
// Single identity maps are removed.
// CHECK: func @f0(memref<2x4xi8, 1>)
func @f0(memref<2x4xi8, #map0, 1>)
@@ -343,3 +346,6 @@ func @f52(memref<1xi8, #map52>)
// CHECK: func @f53(memref<1xi8, #map{{[0-9]+}}>)
func @f53(memref<1xi8, #map53>)
+
+// CHECK: func @f54(memref<10xi32, #map{{[0-9]+}}>)
+func @f54(memref<10xi32, #map54>)
OpenPOWER on IntegriCloud