This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 5/6]tree-sra.c: Fix completely_scalarize for negative array indices
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: gcc-patches at gcc dot gnu dot org, Alan Lawrence <alan dot lawrence at arm dot com>
- Date: Fri, 30 Oct 2015 11:54:08 +0100
- Subject: Re: [PATCH 5/6]tree-sra.c: Fix completely_scalarize for negative array indices
- Authentication-results: sourceware.org; auth=none
- References: <1446146302-17002-1-git-send-email-alan dot lawrence at arm dot com> <1446146302-17002-6-git-send-email-alan dot lawrence at arm dot com> <CAFiYyc33zU6E50g0BMUVQ2y-J0fCQ8hiEYk+RxqBL_UfWxLHWQ at mail dot gmail dot com>
> I think you want to use wide-ints here and
>
> wide_int idx = wi::from (minidx, TYPE_PRECISION (TYPE_DOMAIN
> (...)), TYPE_SIGN (TYPE_DOMAIN (..)));
> wide_int maxidx = ...
>
> you can then simply iterate minidx with ++ and do the final compare
> against maxidx
> with while (++idx <= maxidx). For the array ref index we want to use
> TYPE_DOMAIN
> as type as well, not size_int. Thus wide_int_to_tree (TYPE_DOMAIN
> (...)..idx).
Yes, you generally cannot use HOST_WIDE_INT to avoid overflow because this
will break for 64-bit HOST_WIDE_INT and 32-bit sizetype in corner cases.
But using offset_int should be OK, see for example get_ref_base_and_extent.
--
Eric Botcazou