diff options
author | burnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-04-22 15:33:01 +0000 |
---|---|---|
committer | burnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-04-22 15:33:01 +0000 |
commit | 1d9ee8a89ae88befe5572a65b997cd84241c196f (patch) | |
tree | 646e5ae6929d675514204ffba97ecc64f6157a31 /libgfortran/generated/cshift0_i2.c | |
parent | 0972cc307e81708c54bd5b89c91fe99a84c65d73 (diff) | |
parent | 3c64f1347227c8aceae1822bc66659d861596fc4 (diff) | |
download | gcc-1d9ee8a89ae88befe5572a65b997cd84241c196f.tar.gz |
2012-04-22 Tobias Burnus <burnus@net-b.de>
* Merged Revs. 185177 through 186673 from the trunk.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/fortran-dev@186674 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/generated/cshift0_i2.c')
-rw-r--r-- | libgfortran/generated/cshift0_i2.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/libgfortran/generated/cshift0_i2.c b/libgfortran/generated/cshift0_i2.c index 3f7de844959..d3727a15872 100644 --- a/libgfortran/generated/cshift0_i2.c +++ b/libgfortran/generated/cshift0_i2.c @@ -97,9 +97,13 @@ cshift0_i2 (gfc_array_i2 *ret, const gfc_array_i2 *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) { |