diff --git a/llvm/lib/Transforms/Scalar/LoopInterchange.cpp b/llvm/lib/Transforms/Scalar/LoopInterchange.cpp index b6e071fe5faa7..0162bf1307af0 100644 --- a/llvm/lib/Transforms/Scalar/LoopInterchange.cpp +++ b/llvm/lib/Transforms/Scalar/LoopInterchange.cpp @@ -186,12 +186,8 @@ static bool populateDependencyMatrix(CharMatrix &DepMatrix, unsigned Level, // matrix by exchanging the two columns. static void interChangeDependencies(CharMatrix &DepMatrix, unsigned FromIndx, unsigned ToIndx) { - unsigned numRows = DepMatrix.size(); - for (unsigned i = 0; i < numRows; ++i) { - char TmpVal = DepMatrix[i][ToIndx]; - DepMatrix[i][ToIndx] = DepMatrix[i][FromIndx]; - DepMatrix[i][FromIndx] = TmpVal; - } + for (unsigned I = 0, E = DepMatrix.size(); I < E; ++I) + std::swap(DepMatrix[I][ToIndx], DepMatrix[I][FromIndx]); } // Checks if outermost non '=','S'or'I' dependence in the dependence matrix is