public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenther at suse dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/94734] [10 Regression] Program crashes when compiled with -O2 since r10-1892-gb9ef6a2e04bfd013
Date: Fri, 24 Apr 2020 09:03:55 +0000	[thread overview]
Message-ID: <bug-94734-4-xF6ypbv9Dp@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-94734-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #12 from rguenther at suse dot de <rguenther at suse dot de> ---
On Fri, 24 Apr 2020, jakub at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94734
> 
> --- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
> If we don't want to revert the change completely, could we perhaps do:
> --- gcc/tree-ssa-phiopt.c.jj    2020-03-19 10:23:50.542872359 +0100
> +++ gcc/tree-ssa-phiopt.c       2020-04-24 10:54:10.341716841 +0200
> @@ -2237,10 +2237,26 @@ cond_store_replacement (basic_block midd
>       whose value is not available readily, which we want to avoid.  */
>    if (!nontrap->contains (lhs))
>      {
> -      /* If LHS is a local variable without address-taken, we could
> -        always safely move down the store.  */
> -      tree base = get_base_address (lhs);
> -      if (!auto_var_p (base) || TREE_ADDRESSABLE (base))
> +      /* If LHS is an access to a local variable without address-taken
> +        or its part and the access is provably within the bounds of the
> +        local variable, we could always safely move down the store.  */
> +      HOST_WIDE_INT offset, size, decl_size;
> +      bool reverse;
> +      tree base = get_ref_base_and_extent_hwi (lhs, &offset, &size,
> +                                              &reverse);
> +      if (base == NULL_TREE || !auto_var_p (base) || TREE_ADDRESSABLE (base))
> +       return false;
> +      if (!DECL_SIZE (base)
> +         || !tree_fits_shwi_p (DECL_SIZE (base)))
> +       return false;
> +      decl_size = tree_to_shwi (DECL_SIZE (base));
> +      if (offset < 0
> +         || size < 0
> +         || decl_size < 0
> +         || offset >= decl_size
> +         || size > decl_size
> +         || ((unsigned HOST_WIDE_INT) offset + size
> +             > (unsigned HOST_WIDE_INT) decl_size))
>         return false;
>      }

That should be roughly equivalent to

  if (!nontrap->contains (lhs)
      || !tree_could_trap_p (lhs))

which for ARRAY_REFs checks in_array_bounds_p.

  parent reply	other threads:[~2020-04-24  9:03 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-23 17:17 [Bug c/94734] New: Program crashes when compiled with GCC 10 john+gcc at hogberg dot online
2020-04-23 18:12 ` [Bug c/94734] " john+gcc at hogberg dot online
2020-04-23 19:19 ` [Bug tree-optimization/94734] [10 Regression] Program crashes when compiled with -O2 since r10-1892-gb9ef6a2e04bfd013 marxin at gcc dot gnu.org
2020-04-23 21:24 ` law at redhat dot com
2020-04-23 23:24 ` jakub at gcc dot gnu.org
2020-04-23 23:25 ` jakub at gcc dot gnu.org
2020-04-24  0:48 ` law at redhat dot com
2020-04-24  5:20 ` jakub at gcc dot gnu.org
2020-04-24  7:52 ` rguenth at gcc dot gnu.org
2020-04-24  7:55 ` rguenth at gcc dot gnu.org
2020-04-24  8:34 ` jakub at gcc dot gnu.org
2020-04-24  8:59 ` jakub at gcc dot gnu.org
2020-04-24  9:03 ` rguenther at suse dot de [this message]
2020-04-24  9:09 ` jakub at gcc dot gnu.org
2020-04-24  9:19 ` jakub at gcc dot gnu.org
2020-04-24  9:22 ` rguenth at gcc dot gnu.org
2020-04-24  9:29 ` jakub at gcc dot gnu.org
2020-04-24 10:37 ` jakub at gcc dot gnu.org
2020-04-24 22:10 ` cvs-commit at gcc dot gnu.org
2020-04-24 22:24 ` jakub 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-94734-4-xF6ypbv9Dp@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).