public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.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	[thread overview]
Message-ID: <bug-111715-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111715

            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<N>::set_len(unsigned int, bool)
[with int N = 576]',
    inlined from 'void wi::copy(T1&, const T2&) [with T1 =
widest_int_storage<576>; T2 = generic_wide_int<wide_int_ref_storage<true, true>
>]' at ../../gcc/wide-int.h:2407:13,
    inlined from 'widest_int_storage<N>& widest_int_storage<N>::operator=(const
T&) [with T = int; int N = 576]' at ../../gcc/wide-int.h:1805:12,
    inlined from 'generic_wide_int<storage>&
generic_wide_int<T>::operator=(const T&) [with T = int; storage =
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=]
../../gcc/wide-int.h:1857:12: warning: 'void free(void*)' called on a pointer
to an unallocated object '1' [-Wfree-nonheap-object]
In member function 'void widest_int_storage<N>::set_len(unsigned int, bool)
[with int N = 576]',
    inlined from 'void wi::copy(T1&, const T2&) [with T1 =
widest_int_storage<576>; T2 = generic_wide_int<wide_int_ref_storage<true, true>
>]' at ../../gcc/wide-int.h:2407:13,
    inlined from 'widest_int_storage<N>& widest_int_storage<N>::operator=(const
T&) [with T = int; int N = 576]' at ../../gcc/wide-int.h:1805:12,
    inlined from 'generic_wide_int<storage>&
generic_wide_int<T>::operator=(const T&) [with T = int; storage =
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=]
../../gcc/wide-int.h:1857:12: warning: 'void free(void*)' called on a pointer
to an unallocated object '1' [-Wfree-nonheap-object]

that's caused by failing to CSE in

  MEM <struct aff_tree> [(struct widest_int_storage
*)comb_13(D)].elts[_6].coef.D.132464.len = 1;
  _49 = (sizetype) _6;
  _50 = _49 * 88;
  _101 = _50 + 104;
  _74 = comb_13(D) + _101;
  *_74 = 1;
  _80 = MEM <struct aff_tree> [(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.

             reply	other threads:[~2023-10-06 15:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-06 15:06 rguenth at gcc dot gnu.org [this message]
2023-10-06 15:07 ` [Bug tree-optimization/111715] " rguenth at gcc dot gnu.org
2023-10-06 15:09 ` rguenth at gcc dot gnu.org
2023-10-09 11:12 ` rguenth at gcc dot gnu.org
2023-10-09 13:20 ` cvs-commit at gcc dot gnu.org
2023-10-09 13:20 ` rguenth at gcc dot gnu.org
2023-10-09 21:34 ` sjames at gcc dot gnu.org
2023-10-10  6:46 ` rguenth at gcc dot gnu.org
2023-10-10  6:58 ` sjames at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-111715-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).