diff --git a/mlir/lib/Analysis/Presburger/Utils.cpp b/mlir/lib/Analysis/Presburger/Utils.cpp --- a/mlir/lib/Analysis/Presburger/Utils.cpp +++ b/mlir/lib/Analysis/Presburger/Utils.cpp @@ -172,9 +172,9 @@ expr.resize(cst.getNumCols(), 0); for (unsigned i = 0, e = cst.getNumIds(); i < e; ++i) if (i != pos) - expr[i] = signDiv * cst.atEq(eqInd, i); + expr[i] = -signDiv * cst.atEq(eqInd, i); - expr.back() = signDiv * cst.atEq(eqInd, cst.getNumCols() - 1); + expr.back() = -signDiv * cst.atEq(eqInd, cst.getNumCols() - 1); normalizeDivisionByGCD(expr, divisor); return success(); diff --git a/mlir/unittests/Analysis/Presburger/IntegerPolyhedronTest.cpp b/mlir/unittests/Analysis/Presburger/IntegerPolyhedronTest.cpp --- a/mlir/unittests/Analysis/Presburger/IntegerPolyhedronTest.cpp +++ b/mlir/unittests/Analysis/Presburger/IntegerPolyhedronTest.cpp @@ -725,7 +725,7 @@ // Convert `q` to a local variable. poly.convertToLocal(IdKind::SetDim, 2, 3); - std::vector> divisions = {{-1, -1, 0, 0}}; + std::vector> divisions = {{1, 1, 0, 0}}; SmallVector denoms = {4}; checkDivisionRepresentation(poly, divisions, denoms); @@ -735,7 +735,7 @@ // Convert `q` to a local variable. poly.convertToLocal(IdKind::SetDim, 2, 3); - std::vector> divisions = {{-1, -1, 0, 0}}; + std::vector> divisions = {{1, 1, 0, 0}}; SmallVector denoms = {4}; checkDivisionRepresentation(poly, divisions, denoms); @@ -745,7 +745,7 @@ // Convert `q` to a local variable. poly.convertToLocal(IdKind::SetDim, 2, 3); - std::vector> divisions = {{1, 1, 0, -2}}; + std::vector> divisions = {{-1, -1, 0, 2}}; SmallVector denoms = {3}; checkDivisionRepresentation(poly, divisions, denoms); @@ -761,7 +761,7 @@ poly.convertToLocal(IdKind::SetDim, 2, 4); std::vector> divisions = {{1, 1, 0, 0, 1}, - {-1, -1, 0, 0, 0}}; + {1, 1, 0, 0, 0}}; SmallVector denoms = {4, 3}; checkDivisionRepresentation(poly, divisions, denoms);