From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29394 invoked by alias); 20 Sep 2006 22:21:34 -0000 Received: (qmail 29344 invoked by uid 48); 20 Sep 2006 22:21:27 -0000 Date: Wed, 20 Sep 2006 22:21:00 -0000 Subject: [Bug tree-optimization/29156] New: Misscompilation due to alias analysis X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "rakdver at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2006-09/txt/msg01952.txt.bz2 List-Id: 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 ; xb_3->sub.a = 1; # SMT.4_10 = V_MAY_DEF ; xa_4->a = 8; # VUSE ; 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