[Mlir-commits] [mlir] [mlir][presburger] Implement moveColumns using std::rotate (PR #168243)
Arjun P
llvmlistbot at llvm.org
Mon Dec 1 07:20:26 PST 2025
================
@@ -276,23 +270,23 @@ void Matrix<T>::moveColumns(unsigned srcPos, unsigned num, unsigned dstPos) {
assert(dstPos + num <= getNumColumns() &&
"move destination range exceeds matrix columns");
- unsigned insertCount = offset > 0 ? offset : -offset;
- unsigned finalAdjStart = offset > 0 ? srcPos : srcPos + num;
- unsigned curAdjStart = offset > 0 ? srcPos + num : dstPos;
- // TODO: This can be done using std::rotate.
- // Insert new zero columns in the positions where the adjacent columns are to
- // be moved.
- insertColumns(finalAdjStart, insertCount);
- // Update curAdjStart if insertion of new columns invalidates it.
- if (finalAdjStart < curAdjStart)
- curAdjStart += insertCount;
-
- // Swap the adjacent columns with inserted zero columns.
- for (unsigned i = 0; i < insertCount; ++i)
- swapColumns(finalAdjStart + i, curAdjStart + i);
-
- // Delete the now redundant zero columns.
- removeColumns(curAdjStart, insertCount);
+ unsigned numRows = getNumRows();
+
+ if (offset > 0) {
----------------
Superty wrote:
I don't understand the reason for the offset variable here, can't we just use conditions `dstPos == srcPos`, `dstPos > srcPos`, etc.?
https://github.com/llvm/llvm-project/pull/168243
More information about the Mlir-commits
mailing list