From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18814 invoked by alias); 26 Sep 2003 10:55:10 -0000 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 Received: (qmail 18795 invoked by uid 48); 26 Sep 2003 10:55:08 -0000 Date: Fri, 26 Sep 2003 14:55:00 -0000 From: "aph at gcc dot gnu dot org" To: gcc-bugs@gcc.gnu.org Message-ID: <20030926105501.12419.aph@gcc.gnu.org> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug optimization/12419] New: Performace regression: poor optimization of const memory X-Bugzilla-Reason: CC X-SW-Source: 2003-09/txt/msg02006.txt.bz2 List-Id: PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12419 Summary: Performace regression: poor optimization of const memory Product: gcc Version: 3.4 Status: UNCONFIRMED Severity: normal Priority: P2 Component: optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: aph at gcc dot gnu dot org CC: gcc-bugs at gcc dot gnu dot org This program: extern const int a[]; extern void f(); int foo () { int n = a[0]; f(); n += a[0]; return n; } generates this code: foo: pushl %ebx subl $8, %esp movl a, %ebx call f movl a, %eax addl $8, %esp addl %eax, %ebx movl %ebx, %eax popl %ebx ret Note that the memory 'a' is read twice. 3.2 did this: foo: pushl %ebx subl $8, %esp movl a, %ebx sall $1, %ebx call f addl $8, %esp movl %ebx, %eax popl %ebx ret