aboutsummaryrefslogtreecommitdiffstats
path: root/test/monniaux/mod_int_mat/int_mat.c
diff options
context:
space:
mode:
authorDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2019-01-18 17:17:23 +0100
committerDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2019-01-18 17:17:23 +0100
commita873e3fb7164db2be4641b244a63895dfc0660dd (patch)
tree2ab12813a5081d498aadb3e57b923c1fcac9485a /test/monniaux/mod_int_mat/int_mat.c
parent2a1db308610355d66c6baff004702fd00816e25a (diff)
downloadcompcert-kvx-a873e3fb7164db2be4641b244a63895dfc0660dd.tar.gz
compcert-kvx-a873e3fb7164db2be4641b244a63895dfc0660dd.zip
loop transformation
Diffstat (limited to 'test/monniaux/mod_int_mat/int_mat.c')
-rw-r--r--test/monniaux/mod_int_mat/int_mat.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/monniaux/mod_int_mat/int_mat.c b/test/monniaux/mod_int_mat/int_mat.c
index d3e14e26..58f968c1 100644
--- a/test/monniaux/mod_int_mat/int_mat.c
+++ b/test/monniaux/mod_int_mat/int_mat.c
@@ -109,6 +109,39 @@ void modint_mat_mul5(unsigned m, unsigned n, unsigned p,
}
}
+void modint_mat_mul6(unsigned m, unsigned n, unsigned p,
+ modint * c, unsigned stride_c,
+ const modint *a, unsigned stride_a,
+ const modint *b, unsigned stride_b) {
+ const modint *pa_i = a;
+ modint * pc_i = c;
+ for(unsigned i=0; i<m; i++) {
+ for(unsigned k=0; k<p; k++) {
+ const modint *pb_j_k = b+k, *pa_i_j = pa_i;
+ modint total = 0;
+ unsigned j2=0, n2=n/2;
+ if (n2 > 0) {
+ do {
+ modint p0 = *pa_i_j * *pb_j_k;
+ pa_i_j ++;
+ pb_j_k += stride_b;
+ modint p1 = *pa_i_j * *pb_j_k;
+ pa_i_j ++;
+ pb_j_k += stride_b;
+ total += p0 + p1;
+ j2++;
+ } while (j2 < n2);
+ }
+ if (n%2) {
+ total += *pa_i_j * *pb_j_k;
+ }
+ pc_i[k] = total % MODULUS;
+ }
+ pa_i += stride_a;
+ pc_i += stride_c;
+ }
+}
+
modint modint_random(void) {
static uint64_t next = 1325997111;
next = next * 1103515245 + 12345;