From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C48A33858D39; Sat, 11 Dec 2021 19:25:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C48A33858D39 From: "hubicka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/103662] New: TBAA problem in Fortran FE triggering in gfortran.dg/unlimited_polymorphic_3.f03 Date: Sat, 11 Dec 2021 19:25:16 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hubicka 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: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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: Sat, 11 Dec 2021 19:25:16 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103662 Bug ID: 103662 Summary: TBAA problem in Fortran FE triggering in gfortran.dg/unlimited_polymorphic_3.f03 Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: hubicka at gcc dot gnu.org Target Milestone: --- In this testcase we have: void foo (struct __class__STAR_p & restrict tgt) { struct s * ptr1; integer(kind=3D4) _1; [local count: 1073741824]: ptr1_4 =3D *tgt_3(D)._data; _1 =3D *ptr1_4.k; if (_1 !=3D 42) goto ; [0.04%] else goto ; [99.96%] [local count: 429496]: _gfortran_stop_numeric (2, 0); [local count: 1073312329]: return; } The load ptr1_4 =3D *tgt_3(D)._data has alias sets: - Analyzing load: *tgt_3(D)._data - Recording base_set=3D9 ref_set=3D5 Parm 0 param offset:0 offset:0 siz= e:64 max_size:64 - Analyzing load: *ptr1_4.k - Recording base_set=3D11 ref_set=3D2=20 Now the value is set in main: void MAIN__ () { integer(kind=3D8) y$_len; struct __vtype__STAR * {ref-all} y$_vptr; void * y$_data; struct __class__STAR_p z; struct __class__STAR_p y; struct sq x; static struct __vtype_main_Sq __vtab_main_Sq =3D {._hash=3D85658372, ._si= ze=3D4, ._extends=3D0B, ._def_init=3D&__def_init_main_Sq, ._copy=3D__copy_main_Sq, ._final=3D0B, ._deallocate=3D0B}; static struct sq __def_init_main_Sq; [local count: 1073741824]: x.i =3D 42; z._vptr =3D &__vtab_main_Sq; z._len =3D 0; z._data =3D &x; foo (&z); bar (); x =3D{v} {CLOBBER}; y =3D{v} {CLOBBER}; z =3D{v} {CLOBBER}; return; } here however the z._data store is: ipa-modref: call stmt foo (&z);=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20 ipa-modref: call to foo/0 does not use ref: z._data alias sets: 4->5=20=20= =20=20=20=20=20=20=20=20=20=20 Deleted dead store: z._data =3D &x;=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20 So it has base alias set 4 which is not considered aliasing with alias set = 9.=20 With mainline version of modref we do not perform the optimization because = we are paranoid about _gfortran_stop_numeric (2, 0); possibly accessing someth= ing. If this is replaced by code that does not perform call we get wrong code wi= th -Os. So __class__STAR_p is produced twice while it should not be.=