From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BFEF6385828E; Fri, 6 Oct 2023 15:06:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BFEF6385828E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1696604811; bh=lZ345Xz1zV+JNNfLcwDopRCafOSRzYSIMNvrLhfKAN0=; h=From:To:Subject:Date:From; b=WIGj5vdJaGt8XnC1u2kjLU3PovviIWPrRsjPvm8JQ27rMXhkO36OfbwkGtRhWNHg+ vIL0XkbPCRla5dHWWCGK39vrSVtSEywS3LRzMQ5p4EJgXkRjHmEzFFwyY5u/kiEtO5 Mo105+A4WxDhs0b6UI2Tc/MPAaXt72n+1GSnMnT0= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/111715] New: Missed optimization in FRE because of weak TBAA Date: Fri, 06 Oct 2023 15:06:51 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111715 Bug ID: 111715 Summary: Missed optimization in FRE because of weak TBAA Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: rguenth at gcc dot gnu.org Target Milestone: --- Jakub reports a spurious diagnostic with tree-affine.cc with the wide-int patches: > ./cc1plus -quiet -O2 -Wall -fno-exceptions /tmp/t.ii In file included from ../../gcc/coretypes.h:465, from ../../gcc/tree-affine.cc:22: In member function 'void widest_int_storage::set_len(unsigned int, bool) [with int N =3D 576]', inlined from 'void wi::copy(T1&, const T2&) [with T1 =3D widest_int_storage<576>; T2 =3D generic_wide_int >]' at ../../gcc/wide-int.h:2407:13, inlined from 'widest_int_storage& widest_int_storage::operator=3D= (const T&) [with T =3D int; int N =3D 576]' at ../../gcc/wide-int.h:1805:12, inlined from 'generic_wide_int& generic_wide_int::operator=3D(const T&) [with T =3D int; storage =3D widest_int_storage<576>]' at ../../gcc/wide-int.h:1018:23, inlined from 'void aff_combination_remove_elt(aff_tree*, unsigned int)'= at ../../gcc/tree-affine.cc:596:34: ../../gcc/wide-int.h:1856:14: warning: 'void* memcpy(void*, const void*, size_t)' offset [0, 7] is out of the bounds [0, 0] [-Warray-bounds=3D] ../../gcc/wide-int.h:1857:12: warning: 'void free(void*)' called on a point= er to an unallocated object '1' [-Wfree-nonheap-object] In member function 'void widest_int_storage::set_len(unsigned int, bool) [with int N =3D 576]', inlined from 'void wi::copy(T1&, const T2&) [with T1 =3D widest_int_storage<576>; T2 =3D generic_wide_int >]' at ../../gcc/wide-int.h:2407:13, inlined from 'widest_int_storage& widest_int_storage::operator=3D= (const T&) [with T =3D int; int N =3D 576]' at ../../gcc/wide-int.h:1805:12, inlined from 'generic_wide_int& generic_wide_int::operator=3D(const T&) [with T =3D int; storage =3D widest_int_storage<576>]' at ../../gcc/wide-int.h:1018:23, inlined from 'void aff_combination_convert(aff_tree*, tree)' at ../../gcc/tree-affine.cc:256:34: ../../gcc/wide-int.h:1856:14: warning: 'void* memcpy(void*, const void*, size_t)' offset [0, 7] is out of the bounds [0, 0] [-Warray-bounds=3D] ../../gcc/wide-int.h:1857:12: warning: 'void free(void*)' called on a point= er to an unallocated object '1' [-Wfree-nonheap-object] that's caused by failing to CSE in MEM [(struct widest_int_storage *)comb_13(D)].elts[_6].coef.D.132464.len =3D 1; _49 =3D (sizetype) _6; _50 =3D _49 * 88; _101 =3D _50 + 104; _74 =3D comb_13(D) + _101; *_74 =3D 1; _80 =3D MEM [(struct widest_int_storage *)comb_13(D)].elts[_6].coef.D.132464.len; where the view-convert pun in the MEM_REF makes it get the alias set of wide-int storage which conflicts with the *_74 store of a 'long'. We fail to pick up the store to an 'int' (the len) and possible disambiguation with TBAA. That's somewhat by design since we are faced with a lot of address-taking and dereferencing of pointers as part of C++ abstraction. But the "tail" is still a valid access.=