summaryrefslogtreecommitdiff
path: root/libgfortran/generated/cshift0_r10.c
diff options
context:
space:
mode:
authormatz <matz@138bc75d-0d04-0410-961f-82ee72b054a4>2012-04-10 15:39:22 +0000
committermatz <matz@138bc75d-0d04-0410-961f-82ee72b054a4>2012-04-10 15:39:22 +0000
commit37598f0f97ec961cee103989521a56a682b6be04 (patch)
tree669ecf00bcc15e616e0b3f79d838b063f7331a93 /libgfortran/generated/cshift0_r10.c
parent03ad17bf88b0fb3cf7dccdc92bbb8a4cd3be3b7c (diff)
downloadgcc-37598f0f97ec961cee103989521a56a682b6be04.tar.gz
* m4/cshift0.m4 (cshift0_'rtype_code`): Guard use of modulo.
* generated/cshift0_c10.c: Regenerated. * generated/cshift0_c16.c: Regenerated. * generated/cshift0_c4.c: Regenerated. * generated/cshift0_c8.c: Regenerated. * generated/cshift0_i16.c: Regenerated. * generated/cshift0_i1.c: Regenerated. * generated/cshift0_i2.c: Regenerated. * generated/cshift0_i4.c: Regenerated. * generated/cshift0_i8.c: Regenerated. * generated/cshift0_r10.c: Regenerated. * generated/cshift0_r16.c: Regenerated. * generated/cshift0_r4.c: Regenerated. * generated/cshift0_r8.c: Regenerated. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@186283 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/generated/cshift0_r10.c')
-rw-r--r--libgfortran/generated/cshift0_r10.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/libgfortran/generated/cshift0_r10.c b/libgfortran/generated/cshift0_r10.c
index b7f21caffb2..14be6832123 100644
--- a/libgfortran/generated/cshift0_r10.c
+++ b/libgfortran/generated/cshift0_r10.c
@@ -97,9 +97,13 @@ cshift0_r10 (gfc_array_r10 *ret, const gfc_array_r10 *array, ptrdiff_t shift,
rptr = ret->base_addr;
sptr = array->base_addr;
- shift = len == 0 ? 0 : shift % (ptrdiff_t)len;
- if (shift < 0)
- shift += len;
+ /* Avoid the costly modulo for trivially in-bound shifts. */
+ if (shift < 0 || shift >= len)
+ {
+ shift = len == 0 ? 0 : shift % (ptrdiff_t)len;
+ if (shift < 0)
+ shift += len;
+ }
while (rptr)
{