Skip to content

Commit eeb2ca4

Browse files
update code.
1 parent aeb6c1c commit eeb2ca4

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

mlir/lib/Analysis/Presburger/Matrix.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,7 @@ void Matrix<T>::moveColumns(unsigned srcPos, unsigned num, unsigned dstPos) {
261261
if (num == 0)
262262
return;
263263

264-
int offset = dstPos - srcPos;
265-
if (offset == 0)
264+
if (dstPos == srcPos)
266265
return;
267266

268267
assert(srcPos + num <= getNumColumns() &&
@@ -272,18 +271,16 @@ void Matrix<T>::moveColumns(unsigned srcPos, unsigned num, unsigned dstPos) {
272271

273272
unsigned numRows = getNumRows();
274273

275-
if (offset > 0) {
276-
// Shift the matrix left, because start < end, that std::rotate(start,
277-
// middle, end) turns the range [start, end] to [middle, end) + [start,
278-
// middle).
274+
if (dstPos > srcPos) {
275+
// std::rotate(start, middle, end) permutes the elements of [start, end] to
276+
// [middle, end) + [start, middle).
279277
for (unsigned i = 0; i < numRows; ++i) {
280278
std::rotate(&at(i, srcPos), &at(i, srcPos) + num, &at(i, dstPos) + num);
281279
}
282280
return;
283281
}
284-
// Shift the matrix right. because end < start, that std::rotate(start,
285-
// middle, end) turns the range [start, end] to [middle, start) + [end,
286-
// middle).
282+
// std::rotate(start, middle, end) permutes the elements of [start, end] to
283+
// [middle, start) + [end, middle).
287284
for (unsigned i = 0; i < numRows; ++i) {
288285
std::rotate(&at(i, dstPos), &at(i, srcPos), &at(i, srcPos) + num);
289286
}

0 commit comments

Comments
 (0)