aboutsummaryrefslogtreecommitdiffstats
path: root/test/monniaux/float_mat/float_mat.c
diff options
context:
space:
mode:
authorDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2019-02-19 12:48:00 +0100
committerDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2019-02-19 12:48:00 +0100
commit3f39d34b6f711d8dde42b0d48889c6d4b67ce541 (patch)
tree35757cb047a5fbb9ef6884150108840f54762d48 /test/monniaux/float_mat/float_mat.c
parentc4296102ae17e434279ed82df0471b7c50ab2f51 (diff)
downloadcompcert-kvx-3f39d34b6f711d8dde42b0d48889c6d4b67ce541.tar.gz
compcert-kvx-3f39d34b6f711d8dde42b0d48889c6d4b67ce541.zip
mul8: loop-invariant code motion
Diffstat (limited to 'test/monniaux/float_mat/float_mat.c')
-rw-r--r--test/monniaux/float_mat/float_mat.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/monniaux/float_mat/float_mat.c b/test/monniaux/float_mat/float_mat.c
index 818dbded..45612635 100644
--- a/test/monniaux/float_mat/float_mat.c
+++ b/test/monniaux/float_mat/float_mat.c
@@ -1,4 +1,5 @@
#include "float_mat.h"
+#include <stddef.h>
#define ADD +=
#define MUL *
@@ -180,3 +181,48 @@ void REAL_mat_mul7(unsigned m, unsigned n, unsigned p,
pc_i += stride_c;
}
}
+
+#undef CHUNK
+#define CHUNK \
+ total ADD (*pa_i_j MUL *pb_j_k); \
+ pa_i_j ++; \
+ pb_j_k = (REAL*) ((char*) pb_j_k + stride_b_scaled);
+
+void REAL_mat_mul8(unsigned m, unsigned n, unsigned p,
+ REAL * c, unsigned stride_c,
+ const REAL *a, unsigned stride_a,
+ const REAL *b, unsigned stride_b) {
+ const REAL *pa_i = a;
+ REAL * pc_i = c;
+ size_t stride_b_scaled = sizeof(REAL) * stride_b;
+ for(unsigned i=0; i<m; i++) {
+ for(unsigned k=0; k<p; k++) {
+ const REAL *pb_j_k = b+k, *pa_i_j = pa_i;
+ REAL total = 0;
+ {
+ unsigned j4=0, n4=n/UNROLL;
+ if (n4 > 0) {
+ do {
+ CHUNK
+ CHUNK
+ CHUNK
+ CHUNK
+ j4++;
+ } while (j4 < n4);
+ }
+ }
+ {
+ unsigned j4=0, n4=n%UNROLL;
+ if (n4 > 0) {
+ do {
+ CHUNK
+ j4++;
+ } while (j4 < n4);
+ }
+ }
+ pc_i[k] = total;
+ }
+ pa_i += stride_a;
+ pc_i += stride_c;
+ }
+}