From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1615 invoked by alias); 4 Oct 2011 16:48:54 -0000 Received: (qmail 1597 invoked by uid 22791); 4 Oct 2011 16:48:48 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_TM 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; Tue, 04 Oct 2011 16:48:33 +0000 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/49279] [4.5/4.6/4.7 Regression] Optimization incorrectly presuming constant variable inside loop in g++ 4.5 and 4.6 with -O2 and -O3 for x86_64 targets Date: Tue, 04 Oct 2011 16:48: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: wrong-code X-Bugzilla-Severity: major X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.5.4 X-Bugzilla-Changed-Fields: CC 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: 2011-10/txt/msg00202.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49279 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #5 from Jakub Jelinek 2011-10-04 16:47:22 UTC --- Looking at this (don't see how this is related to the other PR), I think the bug is either that we have these TYPE_RESTRICT casts (caused by storing a non-restricted pointer into a restricted field) in the IL at all, or that we are propagating the restrict tags through the restricted field which we have decided not to have a restrict tag for. If it is a field that can have a restrict tag safely attached to it (restrict field in a structure argument, or DECL_BY_REFERENCE/restrict REFERENCE_TYPE argument pointed structure, or global variable field, or perhaps automatic variable without address taken, the casts for store to it should either not have (restr) at all, or at least should use the same restrict tag as the field. But if the field can't have safely a restrict tag, if we make it up because of the casts for store to it, different stores might be with different tags and if two different pointers alias and PTA doesn't figure it out, we have expressions based on the same restricted field with different restrict tags and miscompile. Now the question is how to safely find out what is a cast for store from other casts. TYPE_RESTRICT casts from non-restrict pointers feeding one stmt which stores it into restricted field? Or should we just say such casts shouldn't be in the IL? Or should only TYPE_RESTRICT casts to SSA_NAMEs of non-artificial vars be considered? In the testcase, all the __restrict casts are casts for store into some field that can't have safely a restrict tag attached: # PT = nonlocal escaped { D.7761 } (restr) data.11D.7427_92 = (const ScalarD.4717 * restrict) D.7426_91; # .MEMD.7374_151 = VDEF <.MEMD.7374_52> MEM[(struct MapBaseD.4571 *)&D.4884].m_dataD.4766 = data.11D.7427_92;