public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rakdver at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/29156]  New: Misscompilation due to alias analysis
Date: Wed, 20 Sep 2006 22:21:00 -0000	[thread overview]
Message-ID: <bug-29156-5077@http.gcc.gnu.org/bugzilla/> (raw)

The testcase below gets misscompiled at -O2.

The alias info looks this way:

Dereferenced pointers

xa, UID 1527, struct test1 *, symbol memory tag: SMT.4, default def: xa_4
xb, UID 1528, struct test2 *, symbol memory tag: SMT.5, default def: xb_3

Symbol memory tags

SMT.4, UID 1547, struct test1, is addressable, is global, call clobbered, may
aliases: { global }
SMT.5, UID 1548, struct test2, is addressable, is global, call clobbered, may
aliases: { global }

The alias sets for SMT.4 and SMT.5 intersect, so everything looks OK here. 
However, access_can_touch_variable (correctly) determines that the dereferences
of xa and xb cannot touch "global"; hence we create the following virual
operands:

  #   SMT.5_8 = V_MAY_DEF <SMT.5_7>;
  xb_3->sub.a = 1;
  #   SMT.4_10 = V_MAY_DEF <SMT.4_9>;
  xa_4->a = 8;
  #   VUSE <SMT.5_8>;
  D.1531_5 = xb_3->sub.a;

The accesses to xa and xb appear to be independent, which leads to a
misscompilation.

struct test1
{
  int a;
  int b;
};
struct test2
{
  float d;
  struct test1 sub;
};

int global;

int bla(struct test1 *xa, struct test2 *xb)
{
  global = 1;
  xb->sub.a = 1;
  xa->a = 8;
  return xb->sub.a;
}

int main(void)
{
  struct test2 pom;

  if (bla (&pom.sub, &pom) != 8)
    abort ();

  return 0;
}


-- 
           Summary: Misscompilation due to alias analysis
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rakdver at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux
  GCC host triplet: i686-pc-linux
GCC target triplet: i686-pc-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29156


             reply	other threads:[~2006-09-20 22:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-20 22:21 rakdver at gcc dot gnu dot org [this message]
2006-09-20 22:26 ` [Bug tree-optimization/29156] [4.2 Regression] Misscompilation due to struct alias pinskia at gcc dot gnu dot org
2006-09-20 22:26 ` pinskia at gcc dot gnu dot org
2006-09-21  2:32 ` dberlin at gcc dot gnu dot org
2006-09-21  2:36 ` mmitchel at gcc dot gnu dot org
2006-09-21  4:06 ` pinskia at gcc dot gnu dot org
2006-09-21  4:23 ` [Bug tree-optimization/29156] [4.2 Regression] Misscompilation with structs due to new " pinskia at gcc dot gnu dot org
2006-09-21 12:15 ` dberlin at dberlin dot org
2006-09-21 12:22 ` rakdver at atrey dot karlin dot mff dot cuni dot cz
2006-10-13 17:51 ` dberlin at gcc dot gnu dot org
2006-10-19 23:06 ` dberlin at gcc dot gnu dot org
2006-10-19 23:07 ` dberlin at gcc dot gnu dot 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-29156-5077@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).