[llvm] ea1a1eb - [NFC] Use std::swap in LoopInterchange

Ta-Wei Tu via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 1 19:42:58 PST 2021


Author: Ta-Wei Tu
Date: 2021-03-02T11:42:48+08:00
New Revision: ea1a1ebbc673d810f1abf6cb58a40b5ec916ff07

URL: https://github.com/llvm/llvm-project/commit/ea1a1ebbc673d810f1abf6cb58a40b5ec916ff07
DIFF: https://github.com/llvm/llvm-project/commit/ea1a1ebbc673d810f1abf6cb58a40b5ec916ff07.diff

LOG: [NFC] Use std::swap in LoopInterchange

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/LoopInterchange.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/LoopInterchange.cpp b/llvm/lib/Transforms/Scalar/LoopInterchange.cpp
index b6e071fe5faa..0162bf1307af 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


        


More information about the llvm-commits mailing list