From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7175 invoked by alias); 11 Apr 2012 13:37:37 -0000 Received: (qmail 7103 invoked by uid 22791); 11 Apr 2012 13:37:36 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,KHOP_THREADED X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 11 Apr 2012 13:37:18 +0000 From: "aldyh at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/52558] write introduction incorrect wrt the C++11 memory model Date: Wed, 11 Apr 2012 13:37:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: aldyh at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: aldyh at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-04/txt/msg00730.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52558 --- Comment #16 from Aldy Hernandez 2012-04-11 13:37:17 UTC --- (In reply to comment #15) > Both value-numbering (FRE/PRE, that do not run after store motion :/) and > DOM should figure this out. DOM only in theory, but at least in this simple > case it should figure it out. Do you have a testcase that does not require > your patches? On a pristine trunk I don't have the exact problem (since the equality in comment 14 was created by my WIP), but I do have a similar problem where no optimization can figure out that g_2_lsm == g_2. Here is a variation of the PR testcase: int g_1 = 1; int g_2 = 0; int func_1(void) { int l; for (l = 0; l < 1234; l++) { if (g_1) return l; else g_2 = 0; } return 999; } On pristine trunk, we get: # VUSE <.MEM_9(D)> g_2_lsm.6_12 = g_2; <-- g_2_lsm = g_2 if (pretmp.4_1 != 0) goto ; else goto ; : # .MEM_8 = VDEF <.MEM_9(D)> g_2 = 0; goto ; : # .MEM_16 = VDEF <.MEM_9(D)> g_2 = g_2_lsm.6_12; <-- g_2_lsm == g_2!! This may actually be the problem in this PR. If we could figure out that g_2_lsm == g_2, there would be no write to g_2 on the g_1!=0 arm of the conditional. Should DOM be able to figure out that g_2_lsm == g_2 in this case as well? Thanks.