diff options
author | tkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-07-09 19:09:33 +0000 |
---|---|---|
committer | tkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-07-09 19:09:33 +0000 |
commit | 829231a6af3d9f01502fea6eb21eaa66976d6c1b (patch) | |
tree | 2caab511caafff148913ed01787320db240010f9 /libgfortran | |
parent | 84066338f533756496dc8ce09726fe8dad8b0cf5 (diff) | |
download | gcc-829231a6af3d9f01502fea6eb21eaa66976d6c1b.tar.gz |
2017-06-09 Thomas Koenig <tkoenig@gcc.gnu.org>
* intrinsics/eoshift2.c (eoshift2): Use memcpy
for innermost copy where possible.
* m4/eoshift1.m4 (eoshift1): Likewise.
* m4/eoshift3.m4 (eoshift3): Likewise.
* generated/eoshift1_16.c: Regenerated.
* generated/eoshift1_4.c: Regenerated.
* generated/eoshift1_8.c: Regenerated.
* generated/eoshift3_16.c: Regenerated.
* generated/eoshift3_4.c: Regenerated.
* generated/eoshift3_8.c: Regenerated.
2017-06-09 Thomas Koenig <tkoenig@gcc.gnu.org>
* gfortran.dg/eoshift_4.f90: New test.
* gfortran.dg/eoshift_5.f90: New test.
* gfortran.dg/eoshift_6.f90: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@250085 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran')
-rw-r--r-- | libgfortran/ChangeLog | 13 | ||||
-rw-r--r-- | libgfortran/generated/eoshift1_16.c | 23 | ||||
-rw-r--r-- | libgfortran/generated/eoshift1_4.c | 23 | ||||
-rw-r--r-- | libgfortran/generated/eoshift1_8.c | 23 | ||||
-rw-r--r-- | libgfortran/generated/eoshift3_16.c | 24 | ||||
-rw-r--r-- | libgfortran/generated/eoshift3_4.c | 24 | ||||
-rw-r--r-- | libgfortran/generated/eoshift3_8.c | 24 | ||||
-rw-r--r-- | libgfortran/intrinsics/eoshift2.c | 23 | ||||
-rw-r--r-- | libgfortran/m4/eoshift1.m4 | 23 | ||||
-rw-r--r-- | libgfortran/m4/eoshift3.m4 | 24 |
10 files changed, 170 insertions, 54 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index fb69c81b04b..f34b4df785a 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,16 @@ +2017-06-09 Thomas Koenig <tkoenig@gcc.gnu.org> + + * intrinsics/eoshift2.c (eoshift2): Use memcpy + for innermost copy where possible. + * m4/eoshift1.m4 (eoshift1): Likewise. + * m4/eoshift3.m4 (eoshift3): Likewise. + * generated/eoshift1_16.c: Regenerated. + * generated/eoshift1_4.c: Regenerated. + * generated/eoshift1_8.c: Regenerated. + * generated/eoshift3_16.c: Regenerated. + * generated/eoshift3_4.c: Regenerated. + * generated/eoshift3_8.c: Regenerated. + 2017-07-02 Thomas Koenig <tkoenig@gcc.gnu.org> * intrinsics/eoshift0.c: For contiguous arrays, use diff --git a/libgfortran/generated/eoshift1_16.c b/libgfortran/generated/eoshift1_16.c index 09059497c82..fe2e8ef66ac 100644 --- a/libgfortran/generated/eoshift1_16.c +++ b/libgfortran/generated/eoshift1_16.c @@ -183,12 +183,23 @@ eoshift1 (gfc_array_char * const restrict ret, src = sptr; dest = &rptr[delta * roffset]; } - for (n = 0; n < len - delta; n++) - { - memcpy (dest, src, size); - dest += roffset; - src += soffset; - } + + /* If the elements are contiguous, perform a single block move. */ + if (soffset == size && roffset == size) + { + size_t chunk = size * (len - delta); + memcpy (dest, src, chunk); + dest += chunk; + } + else + { + for (n = 0; n < len - delta; n++) + { + memcpy (dest, src, size); + dest += roffset; + src += soffset; + } + } if (sh < 0) dest = rptr; n = delta; diff --git a/libgfortran/generated/eoshift1_4.c b/libgfortran/generated/eoshift1_4.c index 1be49325895..a90fc2176de 100644 --- a/libgfortran/generated/eoshift1_4.c +++ b/libgfortran/generated/eoshift1_4.c @@ -183,12 +183,23 @@ eoshift1 (gfc_array_char * const restrict ret, src = sptr; dest = &rptr[delta * roffset]; } - for (n = 0; n < len - delta; n++) - { - memcpy (dest, src, size); - dest += roffset; - src += soffset; - } + + /* If the elements are contiguous, perform a single block move. */ + if (soffset == size && roffset == size) + { + size_t chunk = size * (len - delta); + memcpy (dest, src, chunk); + dest += chunk; + } + else + { + for (n = 0; n < len - delta; n++) + { + memcpy (dest, src, size); + dest += roffset; + src += soffset; + } + } if (sh < 0) dest = rptr; n = delta; diff --git a/libgfortran/generated/eoshift1_8.c b/libgfortran/generated/eoshift1_8.c index 51968e5abcd..8be1e050e3d 100644 --- a/libgfortran/generated/eoshift1_8.c +++ b/libgfortran/generated/eoshift1_8.c @@ -183,12 +183,23 @@ eoshift1 (gfc_array_char * const restrict ret, src = sptr; dest = &rptr[delta * roffset]; } - for (n = 0; n < len - delta; n++) - { - memcpy (dest, src, size); - dest += roffset; - src += soffset; - } + + /* If the elements are contiguous, perform a single block move. */ + if (soffset == size && roffset == size) + { + size_t chunk = size * (len - delta); + memcpy (dest, src, chunk); + dest += chunk; + } + else + { + for (n = 0; n < len - delta; n++) + { + memcpy (dest, src, size); + dest += roffset; + src += soffset; + } + } if (sh < 0) dest = rptr; n = delta; diff --git a/libgfortran/generated/eoshift3_16.c b/libgfortran/generated/eoshift3_16.c index 8040b1e71d4..621fd6f0dc8 100644 --- a/libgfortran/generated/eoshift3_16.c +++ b/libgfortran/generated/eoshift3_16.c @@ -198,12 +198,24 @@ eoshift3 (gfc_array_char * const restrict ret, src = sptr; dest = &rptr[delta * roffset]; } - for (n = 0; n < len - delta; n++) - { - memcpy (dest, src, size); - dest += roffset; - src += soffset; - } + + /* If the elements are contiguous, perform a single block move. */ + if (soffset == size && roffset == size) + { + size_t chunk = size * (len - delta); + memcpy (dest, src, chunk); + dest += chunk; + } + else + { + for (n = 0; n < len - delta; n++) + { + memcpy (dest, src, size); + dest += roffset; + src += soffset; + } + } + if (sh < 0) dest = rptr; n = delta; diff --git a/libgfortran/generated/eoshift3_4.c b/libgfortran/generated/eoshift3_4.c index be5827efd70..ac4fd67f3c7 100644 --- a/libgfortran/generated/eoshift3_4.c +++ b/libgfortran/generated/eoshift3_4.c @@ -198,12 +198,24 @@ eoshift3 (gfc_array_char * const restrict ret, src = sptr; dest = &rptr[delta * roffset]; } - for (n = 0; n < len - delta; n++) - { - memcpy (dest, src, size); - dest += roffset; - src += soffset; - } + + /* If the elements are contiguous, perform a single block move. */ + if (soffset == size && roffset == size) + { + size_t chunk = size * (len - delta); + memcpy (dest, src, chunk); + dest += chunk; + } + else + { + for (n = 0; n < len - delta; n++) + { + memcpy (dest, src, size); + dest += roffset; + src += soffset; + } + } + if (sh < 0) dest = rptr; n = delta; diff --git a/libgfortran/generated/eoshift3_8.c b/libgfortran/generated/eoshift3_8.c index b3aff0f62c3..7e9d8b48475 100644 --- a/libgfortran/generated/eoshift3_8.c +++ b/libgfortran/generated/eoshift3_8.c @@ -198,12 +198,24 @@ eoshift3 (gfc_array_char * const restrict ret, src = sptr; dest = &rptr[delta * roffset]; } - for (n = 0; n < len - delta; n++) - { - memcpy (dest, src, size); - dest += roffset; - src += soffset; - } + + /* If the elements are contiguous, perform a single block move. */ + if (soffset == size && roffset == size) + { + size_t chunk = size * (len - delta); + memcpy (dest, src, chunk); + dest += chunk; + } + else + { + for (n = 0; n < len - delta; n++) + { + memcpy (dest, src, size); + dest += roffset; + src += soffset; + } + } + if (sh < 0) dest = rptr; n = delta; diff --git a/libgfortran/intrinsics/eoshift2.c b/libgfortran/intrinsics/eoshift2.c index badba7509ec..5d949dda8bb 100644 --- a/libgfortran/intrinsics/eoshift2.c +++ b/libgfortran/intrinsics/eoshift2.c @@ -181,12 +181,23 @@ eoshift2 (gfc_array_char *ret, const gfc_array_char *array, src = sptr; dest = &rptr[-shift * roffset]; } - for (n = 0; n < len; n++) - { - memcpy (dest, src, size); - dest += roffset; - src += soffset; - } + + /* If the elements are contiguous, perform a single block move. */ + if (soffset == size && roffset == size) + { + size_t chunk = size * len; + memcpy (dest, src, chunk); + dest += chunk; + } + else + { + for (n = 0; n < len; n++) + { + memcpy (dest, src, size); + dest += roffset; + src += soffset; + } + } if (shift >= 0) { n = shift; diff --git a/libgfortran/m4/eoshift1.m4 b/libgfortran/m4/eoshift1.m4 index 3e47d90436e..69504601b35 100644 --- a/libgfortran/m4/eoshift1.m4 +++ b/libgfortran/m4/eoshift1.m4 @@ -184,12 +184,23 @@ eoshift1 (gfc_array_char * const restrict ret, src = sptr; dest = &rptr[delta * roffset]; } - for (n = 0; n < len - delta; n++) - { - memcpy (dest, src, size); - dest += roffset; - src += soffset; - } + + /* If the elements are contiguous, perform a single block move. */ + if (soffset == size && roffset == size) + { + size_t chunk = size * (len - delta); + memcpy (dest, src, chunk); + dest += chunk; + } + else + { + for (n = 0; n < len - delta; n++) + { + memcpy (dest, src, size); + dest += roffset; + src += soffset; + } + } if (sh < 0) dest = rptr; n = delta; diff --git a/libgfortran/m4/eoshift3.m4 b/libgfortran/m4/eoshift3.m4 index b29fbccf8d3..9e7f78755b1 100644 --- a/libgfortran/m4/eoshift3.m4 +++ b/libgfortran/m4/eoshift3.m4 @@ -199,12 +199,24 @@ eoshift3 (gfc_array_char * const restrict ret, src = sptr; dest = &rptr[delta * roffset]; } - for (n = 0; n < len - delta; n++) - { - memcpy (dest, src, size); - dest += roffset; - src += soffset; - } + + /* If the elements are contiguous, perform a single block move. */ + if (soffset == size && roffset == size) + { + size_t chunk = size * (len - delta); + memcpy (dest, src, chunk); + dest += chunk; + } + else + { + for (n = 0; n < len - delta; n++) + { + memcpy (dest, src, size); + dest += roffset; + src += soffset; + } + } + if (sh < 0) dest = rptr; n = delta; |