aboutsummaryrefslogtreecommitdiff
path: root/libgfortran/intrinsics/eoshift2.c
diff options
context:
space:
mode:
authorThomas Koenig <tkoenig@gcc.gnu.org>2017-07-09 19:09:33 +0000
committerThomas Koenig <tkoenig@gcc.gnu.org>2017-07-09 19:09:33 +0000
commitba71a2a62c63f77f4a21c460738dc8795b0f6eac (patch)
tree2caab511caafff148913ed01787320db240010f9 /libgfortran/intrinsics/eoshift2.c
parent35c95658180e67503f9de96567ab4d6e71b10a6e (diff)
downloadgcc-ba71a2a62c63f77f4a21c460738dc8795b0f6eac.zip
gcc-ba71a2a62c63f77f4a21c460738dc8795b0f6eac.tar.gz
gcc-ba71a2a62c63f77f4a21c460738dc8795b0f6eac.tar.bz2
eoshift2.c (eoshift2): Use memcpy for innermost copy where possible.
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. From-SVN: r250085
Diffstat (limited to 'libgfortran/intrinsics/eoshift2.c')
-rw-r--r--libgfortran/intrinsics/eoshift2.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/libgfortran/intrinsics/eoshift2.c b/libgfortran/intrinsics/eoshift2.c
index badba75..5d949dd 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;