diff options
Diffstat (limited to 'libgfortran/generated/cshift0_r16.c')
-rw-r--r-- | libgfortran/generated/cshift0_r16.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/libgfortran/generated/cshift0_r16.c b/libgfortran/generated/cshift0_r16.c index 320b705..6d351f7 100644 --- a/libgfortran/generated/cshift0_r16.c +++ b/libgfortran/generated/cshift0_r16.c @@ -97,9 +97,13 @@ cshift0_r16 (gfc_array_r16 *ret, const gfc_array_r16 *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) { |