From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19515 invoked by alias); 7 Apr 2014 16:01:01 -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 Received: (qmail 19498 invoked by uid 48); 7 Apr 2014 16:00:58 -0000 From: "sunfish at mozilla dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/60778] New: shift not folded into shift on x86-64 Date: Mon, 07 Apr 2014 16:01:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: sunfish at mozilla dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-04/txt/msg00484.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60778 Bug ID: 60778 Summary: shift not folded into shift on x86-64 Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: sunfish at mozilla dot com On this C code: double mem[4096]; double foo(long x) { return mem[x>>3]; } GCC emits this x86-64 code: sarq $3, %rdi movsd mem(,%rdi,8), %xmm0 The following x86-64 code would be preferrable: andq $-8, %rdi movsd mem(%rdi), %xmm0 since it has smaller code size, and avoids using a scaled index which costs an extra micro-op on some microarchitectures. The same situation arrises on 32-bit x86 also. This was observed on all GCC versions currently on the GCC Explorer website [0], with the latest at this time being 4.9.0 20130909. [0] http://gcc.godbolt.org/