diff options
author | Michael Matz <matz@suse.de> | 2012-04-10 15:39:22 +0000 |
---|---|---|
committer | Michael Matz <matz@gcc.gnu.org> | 2012-04-10 15:39:22 +0000 |
commit | b43645b85249fcae9071fc4bcc1e9b54c15b313f (patch) | |
tree | 669ecf00bcc15e616e0b3f79d838b063f7331a93 /libgfortran/generated/cshift0_i4.c | |
parent | ca18edc55f1c23fcaa06aabe07460f4bb56f937f (diff) | |
download | gcc-b43645b85249fcae9071fc4bcc1e9b54c15b313f.zip gcc-b43645b85249fcae9071fc4bcc1e9b54c15b313f.tar.gz gcc-b43645b85249fcae9071fc4bcc1e9b54c15b313f.tar.bz2 |
cshift0.m4 (cshift0_'rtype_code`): Guard use of modulo.
* 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.
From-SVN: r186283
Diffstat (limited to 'libgfortran/generated/cshift0_i4.c')
-rw-r--r-- | libgfortran/generated/cshift0_i4.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/libgfortran/generated/cshift0_i4.c b/libgfortran/generated/cshift0_i4.c index 7d25b7b..d75b4d6 100644 --- a/libgfortran/generated/cshift0_i4.c +++ b/libgfortran/generated/cshift0_i4.c @@ -97,9 +97,13 @@ cshift0_i4 (gfc_array_i4 *ret, const gfc_array_i4 *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) { |