]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Micro-optimize the matinv regression test
authorBart Van Assche <bvanassche@acm.org>
Thu, 28 Jul 2011 17:40:49 +0000 (17:40 +0000)
committerBart Van Assche <bvanassche@acm.org>
Thu, 28 Jul 2011 17:40:49 +0000 (17:40 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11930

drd/tests/matinv.c

index efcb02a7c6eab8090db5d876dc0771814dc72052..1e2608850a29ce69229c31417751bb77ddf80b6c 100644 (file)
@@ -173,6 +173,7 @@ static void gj_threadfunc(struct gj_threadinfo* p)
   elem_t* const a = p->a;
   const int rows = p->rows;
   const int cols = p->cols;
+  elem_t aii;
 
   for (i = 0; i < p->rows; i++)
   {
@@ -197,13 +198,10 @@ static void gj_threadfunc(struct gj_threadinfo* p)
         }
       }
       // Normalize row i.
-      if (a[i * cols + i] != 0)
-      {
-        for (k = cols - 1; k >= 0; k--)
-        {
-          a[i * cols + k] /= a[i * cols + i];
-        }
-      }
+      aii = a[i * cols + i];
+      if (aii != 0)
+        for (k = i; k < cols; k++)
+          a[i * cols + k] /= aii;
     }
     pthread_barrier_wait(p->b);
     // Reduce all rows j != i.