From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5896 invoked by alias); 2 Sep 2006 21:14:24 -0000 Received: (qmail 5875 invoked by uid 48); 2 Sep 2006 21:14:17 -0000 Date: Sat, 02 Sep 2006 21:14:00 -0000 Subject: [Bug tree-optimization/28940] New: Overzealous CSE with static array access X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "lmakhlis at bmc dot com" 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 X-SW-Source: 2006-09/txt/msg00163.txt.bz2 List-Id: char a[10], b[10]; int f1(int i) { return a[i+1] + b[i+1]; } With -O1 and higher, gcc performs CSE on i+1: addl $1, %edi movslq %edi,%rdi movsbl a(%rdi),%eax movsbl b(%rdi),%edx addl %edx, %eax ret This doesn't happen with the equivalent return (&a[0])[i+1] + (&b[0])[i+1]; or return *(a + i + 1) + *(b + i + 1); which both compile to movslq %edi,%rdi movsbl a+1(%rdi),%eax movsbl b+1(%rdi),%edx addl %edx, %eax ret -- Summary: Overzealous CSE with static array access Product: gcc Version: 4.1.1 Status: UNCONFIRMED Severity: minor Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: lmakhlis at bmc dot com GCC build triplet: x86_64-redhat-linux GCC host triplet: x86_64-redhat-linux GCC target triplet: x86_64-redhat-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28940