From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31110 invoked by alias); 17 Sep 2010 09:59:48 -0000 Received: (qmail 31082 invoked by uid 48); 17 Sep 2010 09:59:36 -0000 Date: Fri, 17 Sep 2010 09:59:00 -0000 Message-ID: <20100917095936.31081.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug rtl-optimization/45685] GCC optimizer for Intel x64 generates inefficient code In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "ubizjak at gmail dot com" 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: 2010-09/txt/msg01931.txt.bz2 ------- Comment #4 from ubizjak at gmail dot com 2010-09-17 09:59 ------- This all happens in IF conversion pass. 4.6 regresses in the sense that a branch is emitted instead of cmov for: int summation_helper_1 (long * products, unsigned long count) { int s = 0; unsigned long i; for (i = 0; i < count; i++) { int val = (products[i] > 0) ? 1 : -1; products[i] *= val; if (products[i] != i) val = -val; products[i] = val; s += val; } return s; } gcc-4.4.4 -O3 produces: .L16: movq (%rdi,%rdx,8), %r10 testq %r10, %r10 setg %r8b xorl %ecx, %ecx testq %r10, %r10 movzbl %r8b, %r9d movzbl %r8b, %r8d setle %cl leaq -1(%r8,%r8), %r8 leal -1(%rcx,%rcx), %ecx leal -1(%r9,%r9), %r9d imulq %r8, %r10 movslq %ecx,%r11 cmpq %r10, %rdx cmovne %r11, %r8 cmove %r9d, %ecx movq %r8, (%rdi,%rdx,8) addq $1, %rdx addl %ecx, %eax cmpq %rdx, %rsi ja .L16 and gcc-4.6 20100917 .L15: movq (%rdi,%rdx,8), %r8 testq %r8, %r8 movq %r8, %r10 setg %cl xorl %r9d, %r9d testq %r8, %r8 movzbl %cl, %r11d movzbl %cl, %ecx setle %r9b leaq -1(%rcx,%rcx), %rcx leaq -1(%r9,%r9), %r9 imulq %rcx, %r10 cmpq %r10, %rdx cmove %rcx, %r9 leal -1(%r11,%r11), %ecx movq %r9, (%rdi,%rdx,8) je .L12 xorl %ecx, %ecx testq %r8, %r8 setle %cl leal -1(%rcx,%rcx), %ecx .L12: addq $1, %rdx addl %ecx, %eax cmpq %rsi, %rdx jne .L15 -- ubizjak at gmail dot com changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed|0000-00-00 00:00:00 |2010-09-17 09:59:36 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45685