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/94963] [11 Regression] Spurious uninitialized warning for static variable building glibc
Date: Wed, 06 May 2020 07:38:21 +0000	[thread overview]
Message-ID: <bug-94963-4-IeQPB5qIJX@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-94963-4@http.gcc.gnu.org/bugzilla/>

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2020-05-06
             Status|UNCONFIRMED                 |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
     Ever confirmed|0                           |1
   Target Milestone|---                         |11.0

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  I've met the underlying issue when developing the patch and for
this reason marked the conditional store inserted by LIM with no-warning.
But for the testcase that's not enough since now PRE comes along and
optimizes the var.field load away, re-exposing the issue.

LIM transforms the testcase to (simplified a bit)

void
f (void)
{
  if (pv != 0)
    {
      bool v2_set = false;
      bool varfield_set = false;
      int v2tem, varfield_tem;
    for (const P *ph = pv; ph < &pv[ps]; ++ph)
      switch (ph->p1)
        {
        case 1:
          v2tem = ph->p2;
          v2_set = true;
          break;
        case 2:
          varfield_tem = ph->p3;
          varfield_set = true;
          break;
        }
      if (varfield_set)
        var.field = varfield_tem;
      if (v2_set)
        v2 = v2tem;
     }
  if (var.field != 0)
    foo (&var);
}

where the uninit predicate analysis doesn't grok the relation between
varfield_set and varfield_tem being initialized.

The patch changed code generation to elide the previously emitted
unconditional load of v2 and var.field.  I suspected that for
the case where there is no load the loop PHI for varfield_tem
might be eliminated, but it is not in all cases it seems.  Now
apart from marking the store no-warning we could easily initialize
the tems on loop entry, just not with their true value but for example
with zero.  That might result in less optimal out-of-SSA though
(no coalescing with constants, the constant move needs to be emitted...)
at least when the loop PHI is not eliminated.

What works is initializing with an uninitialized variable marked
TREE_NO_WARNING.  I'm going to test that (eliding the no-warning
on the conditional stores).

  reply	other threads:[~2020-05-06  7:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-05 22:41 [Bug tree-optimization/94963] New: " jsm28 at gcc dot gnu.org
2020-05-06  7:38 ` rguenth at gcc dot gnu.org [this message]
2020-05-06  7:55 ` [Bug tree-optimization/94963] " rguenth at gcc dot gnu.org
2020-05-06 10:36 ` cvs-commit at gcc dot gnu.org
2020-05-06 10:37 ` rguenth 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-94963-4-IeQPB5qIJX@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).