From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C254B3858405; Wed, 30 Mar 2022 09:07:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C254B3858405 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/102043] [9/10/11/12 Regression] Wrong array types used for negative stride accesses, gfortran.dg/vector_subscript_1.f90 FAILs Date: Wed, 30 Mar 2022 09:07:33 +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: rguenth at gcc dot gnu.org 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: 9.5 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: Wed, 30 Mar 2022 09:07:33 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102043 --- Comment #41 from Richard Biener --- -- random ideas dumping below -- so reading about ISO_Fortran_binding.h it seems to be that a base of the ob= ject isn't readily available and making it available would require quite some computation. staying with the current scheme of simply piggy-backing on C [] operator semantics which is, when facing a pointer that is being indexed, equivalent to pointer arithmetic which _can_ advance to before the indexed pointer, looks reasonable. that rules out using ARRAY_REF for all accesses through a descriptor (unless all strides are positive - not sure if it's worth special casing th= at though). it might be helpful to have a tree code providing CFI_address in an expanded form with explicitely specified index, [low-bound,] stride per indexed dimension and with the guarantee of CFI that the dimensions are independent (non-overlapping elements). I'd call it ELEMENT_SELECT_EXPR here, it would not be a tcc_reference since it only computes an address that would need to be dereferenced with a MEM_REF. Since it would be variable-length it doesn't nicely map to GIMPLE. Lowering during gimplification would be possible. Note we already have a vehicle that should be usable for the 1-dimensional case, namely TARGET_MEM_REF which allows variable pointer offsetting with a scaled index. Of course it would be somewhat abusing this and dependence analysis doesn't play nicely with it either AFAIK. Going for selected ARRAY_REF -> POINTER_PLUS_EXPR + MEM_REF lowering sounds like the way of least resistance, but then that's probably backwards of what the OpenACC folks want to do.=