From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B72E63858430; Mon, 14 Mar 2022 14:48:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B72E63858430 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/104696] [OpenMP] component/array-ref/component (x.r[1].d) should use 'x' for GOMP_MAP_STRUCT (not yield 'x.r[1]' for nonptr 'x.r') Date: Mon, 14 Mar 2022 14:48:17 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: missed-optimization, openmp, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: component short_desc 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, 14 Mar 2022 14:48:17 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104696 Tobias Burnus changed: What |Removed |Added ---------------------------------------------------------------------------- Component|fortran |middle-end Summary|[OpenMP] Implicit mapping |[OpenMP] |breaks struct mapping |component/array-ref/compone | |nt (x.r[1].d) should use | |'x' for GOMP_MAP_STRUCT | |(not yield 'x.r[1]' for | |nonptr 'x.r') --- Comment #5 from Tobias Burnus --- (In reply to Tobias Burnus from comment #4) > #pragma omp target map(tofrom: x.r[1].d) > *.r[1].d =3D 3; s/*/x/ The problem is that in gimplify.cc's gimplify_scan_omp_clauses: tree base =3D extract_base_bit_offset (OMP_CLAUSE_DECL (c), &base= _ref, &bitpos1, &offset1, &tree_offset1); bool do_map_struct =3D (base =3D=3D decl && !tree_offset1= ); Here, 'base' =3D=3D 'x' but 'decl' is 'x.r[1]' - while for 'x.q.d' it is 'x= ' (=3D=3D base). The comp refs are removed as follows. (It seems as if some additional ARRAY= _REF checking is needed for non-pointer components.) else if (TREE_CODE (decl) =3D=3D COMPONENT_REF && (OMP_CLAUSE_MAP_KIND (c) !=3D GOMP_MAP_ATTACH_ZERO_LENGTH_ARRAY_SECTION)) {=20 component_ref_p =3D true;=20 while (TREE_CODE (decl) =3D=3D COMPONENT_REF) decl =3D TREE_OPERAND (decl, 0); if (TREE_CODE (decl) =3D=3D INDIRECT_REF && DECL_P (TREE_OPERAND (decl, 0)) && (TREE_CODE (TREE_TYPE (TREE_OPERAND (decl, 0))) =3D=3D REFERENCE_TYPE)) decl =3D TREE_OPERAND (decl, 0); } Probably the same for '!DECL_P (decl)' in the previous 'if' branch.=