From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1618 invoked by alias); 31 Mar 2011 16:11:08 -0000 Received: (qmail 1601 invoked by uid 22791); 31 Mar 2011 16:11:07 -0000 X-SWARE-Spam-Status: No, hits=-2.8 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; Thu, 31 Mar 2011 16:11:02 +0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/48390] New: Multiple setting to restricted pointer variable not optimized away X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Thu, 31 Mar 2011 16:37: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-03/txt/msg03359.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48390 Summary: Multiple setting to restricted pointer variable not optimized away Product: gcc Version: 4.7.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: middle-end AssignedTo: unassigned@gcc.gnu.org ReportedBy: burnus@gcc.gnu.org Missed optimization: In the following program, the first "a = 1" line can be removed - as the setting is not used and the value is latter overridden, however, the line remains even with -O3. function foo (a, b, c, ptr) real :: a, b, c, foo real, pointer :: ptr a = 1 ! Can delete b = ptr + 2 a = 3 foo = a + b end function >>From the -O3 dump: foo (real(kind=4) & restrict a, real(kind=4) & restrict b, real(kind=4) & restrict c, real(kind=4) * & ptr) { [...] *a_1(D) = 1.0e+0; /* Expected: This line is removed. */ [...] *a_1(D) = 3.0e+0; The same result is obtained for the equivalent C program: float foo (float * restrict a, float * restrict b, float * restrict c, float *ptr) { *a = 1; /* Can delete. */ *b = *ptr + 2; *a = 3; return *a + *b; } Reported in by Daniel Carrera at http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/ec8641acbcbbed10/fdc9369d5acf53f1#fdc9369d5acf53f1