From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7CFDE3858411; Mon, 22 Nov 2021 07:46:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7CFDE3858411 From: "rguenther at suse dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/102043] Wrong array types used for negative stride accesses Date: Mon, 22 Nov 2021 07:46:56 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenther at suse dot de X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Nov 2021 07:46:56 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102043 --- Comment #24 from rguenther at suse dot de --- On Fri, 19 Nov 2021, mikael at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102043 >=20 > --- Comment #23 from Mikael Morin --- > (In reply to Richard Biener from comment #21) > > (In reply to Bernhard Reutner-Fischer from comment #17) > > > Do we want to address arrays always at position 0 (maybe to help grap= hite ?) > >=20 > > Helping graphite (and other loop optimizers) would be to not lower > > multi-dimensional accesses to a single dimension (I think that's what > > Sandras patches try to do).=20 >=20 > Or maybe graphite can be taught to handle flattened array access? >=20 > Anyway, does the middle-end support out-of-order array access? > Namely for an array arr(4, 5, 6), arr(:, 1, :) is an array of size (4, 6). > Does the middle-end type system support this? Support as in not miscompile - yes. Dependence analysis is only helped if the shapes of the accesses to the same storage are compatible - a two dimensional and a three dimensional access are not. > In any case, it=E2=80=99s not for gcc 12. Agreed. > > The lower bound doesn't really matter here and > > is well-handled by all code. >=20 > Well, unless the lower bound is negative. ;-) Even a negative lower bound is OK. Problematic is only if you provide an index that accesses the array below the (negative) lower bound ;) But note! In GCC a[i] with a having a lower bound of say -100 will access storage at &a + (i - -100), the lower bound is just to make the effective index >=3D 0 again, so it can't be used (on its own) to solve the present issue as far as I understand since you _do_ need to access the storage at an effective index < 0.=