message: Simplify simplify functions as follow up on previous CL.
  Addressing comment from post submit + simplifying the logic.
diff: @@ -947,13 +947,15 @@ static AffineExpr simplifyFloorDiv(AffineExpr lhs, AffineExpr rhs) {
  auto lhsConst = lhs.dyn_cast<AffineConstantExpr>();
  auto rhsConst = rhs.dyn_cast<AffineConstantExpr>();
  - if (lhsConst && rhsConst && rhsConst.getValue() >= 1)
  + if (!rhsConst || rhsConst.getValue() < 1)
  + return nullptr;
  +
  + if (lhsConst)
  return getAffineConstantExpr(
  floorDiv(lhsConst.getValue(), rhsConst.getValue()), lhs.getContext());
  // Fold floordiv of a multiply with a constant that is a multiple of the
  // divisor. Eg: (i * 128) floordiv 64 = i * 2.
  - if (rhsConst) {
  if (rhsConst.getValue() == 1)
  return lhs;
  @@ -965,7 +967,6 @@ static AffineExpr simplifyFloorDiv(AffineExpr lhs, AffineExpr rhs) {
  return lBin.getLHS() * (lrhs.getValue() / rhsConst.getValue());
  }
  }
  - }
  return nullptr;
  }
  @@ -974,13 +975,15 @@ static AffineExpr simplifyCeilDiv(AffineExpr lhs, AffineExpr rhs) {
  auto lhsConst = lhs.dyn_cast<AffineConstantExpr>();
  auto rhsConst = rhs.dyn_cast<AffineConstantExpr>();
  - if (lhsConst && rhsConst && rhsConst.getValue() >= 1)
  + if (!rhsConst || rhsConst.getValue() < 1)
  + return nullptr;
  +
  + if (lhsConst)
  return getAffineConstantExpr(
  ceilDiv(lhsConst.getValue(), rhsConst.getValue()), lhs.getContext());
  // Fold ceildiv of a multiply with a constant that is a multiple of the
  // divisor. Eg: (i * 128) ceildiv 64 = i * 2.
  - if (rhsConst) {
  if (rhsConst.getValue() == 1)
  return lhs;
  @@ -992,7 +995,6 @@ static AffineExpr simplifyCeilDiv(AffineExpr lhs, AffineExpr rhs) {
  return lBin.getLHS() * (lrhs.getValue() / rhsConst.getValue());
  }
  }
  - }
  return nullptr;
  }
  @@ -1001,18 +1003,18 @@ static AffineExpr simplifyMod(AffineExpr lhs, AffineExpr rhs) {
  auto lhsConst = lhs.dyn_cast<AffineConstantExpr>();
  auto rhsConst = rhs.dyn_cast<AffineConstantExpr>();
  - if (lhsConst && rhsConst && rhsConst.getValue() >= 1)
  + if (!rhsConst || rhsConst.getValue() < 1)
  + return nullptr;
  +
  + if (lhsConst)
  return getAffineConstantExpr(mod(lhsConst.getValue(), rhsConst.getValue()),
  lhs.getContext());
  // Fold modulo of an expression that is known to be a multiple of a constant
  // to zero if that constant is a multiple of the modulo factor. Eg: (i * 128)
  // mod 64 is folded to 0, and less trivially, (i*(j*4*(k*32))) mod 128 = 0.
  - if (rhsConst) {
  - // rhsConst is known to be positive if a constant.
  if (lhs.getLargestKnownDivisor() % rhsConst.getValue() == 0)
  return getAffineConstantExpr(0, lhs.getContext());
  - }
  return nullptr;
  // TODO(bondhugula): In general, this can be simplified more by using the GCD
  