------- 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

Reply via email to