From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30895 invoked by alias); 7 Feb 2011 10:58:08 -0000 Received: (qmail 30884 invoked by uid 22791); 7 Feb 2011 10:58:07 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 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; Mon, 07 Feb 2011 10:58:02 +0000 From: "bonzini at gnu dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/47255] Missed CSE optimization with inline functions, and __attribute__((const)) 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: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: bonzini at gnu dot org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- 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 Date: Mon, 07 Feb 2011 10:58:00 -0000 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-02/txt/msg00837.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47255 Paolo Bonzini changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bonzini at gnu dot org --- Comment #4 from Paolo Bonzini 2011-02-07 10:57:54 UTC --- I think this is invalid. const attributes are a hint to GCC regarding parts of the program that it cannot see, but IMHO the const/pure/nothrow on a function that is static and a leaf should have no effect on code generation (since GCC can infer just as much). So, in the first example GCC is "fixing" a wrong usage of const on part of the program. In the second example attached, there is no use of syscalls and GCC properly optimizes out square2 and square3. If syscalls were added, the bug would be about missed attributes on the syscalls. BTW, getgid, getuid etc. are pure but not const.