Fix AffineExpr printing bug: paren ellision b/117887365.

PiperOrigin-RevId: 217803621
This commit is contained in:
Uday Bondhugula 2018-10-18 18:18:04 -07:00 committed by jpienaar
parent 03b48999b6
commit a55b2c2eb6
2 changed files with 12 additions and 1 deletions

View File

@ -723,7 +723,11 @@ void ModulePrinter::printAffineExprInternal(
if (rrhs.getValue() == -1) {
printAffineExprInternal(binOp.getLHS(), BindingStrength::Weak);
os << " - ";
printAffineExprInternal(rhs.getLHS(), BindingStrength::Weak);
if (rhs.getLHS().getKind() == AffineExprKind::Add) {
printAffineExprInternal(rhs.getLHS(), BindingStrength::Strong);
} else {
printAffineExprInternal(rhs.getLHS(), BindingStrength::Weak);
}
if (enclosingTightness == BindingStrength::Strong)
os << ')';

View File

@ -175,6 +175,10 @@
// CHECK: #map{{[0-9]+}} = (d0) -> (-2, 1, -1)
#map51 = (i) -> (-5 floordiv 3, -5 mod 3, -5 ceildiv 3)
// Parenthesis ellision.
// CHECK: #map{{[0-9]+}} = (d0) -> (d0 * 16 - (d0 + 1) + 15)
#map52 = (d0) -> (16*d0 + ((d0 + 1) * -1) + 15)
// CHECK: extfunc @f0(memref<2x4xi8, #map{{[0-9]+}}, 1>)
extfunc @f0(memref<2x4xi8, #map0, 1>)
@ -345,3 +349,6 @@ extfunc @f50(memref<100x100xi8, #map50>)
// CHECK: extfunc @f51(memref<1xi8, #map{{[0-9]+}}>)
extfunc @f51(memref<1xi8, #map51>)
// CHECK: extfunc @f52(memref<1xi8, #map{{[0-9]+}}>)
extfunc @f52(memref<1xi8, #map52>)