public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/29156]  New: Misscompilation due to alias analysis
@ 2006-09-20 22:21 rakdver at gcc dot gnu dot org
  2006-09-20 22:26 ` [Bug tree-optimization/29156] [4.2 Regression] Misscompilation due to struct alias pinskia at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: rakdver at gcc dot gnu dot org @ 2006-09-20 22:21 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2006-10-19 23:07 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-20 22:21 [Bug tree-optimization/29156] New: Misscompilation due to alias analysis rakdver at gcc dot gnu dot org
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

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).