[Bug rtl-optimization/45685] GCC optimizer for Intel x64 generates inefficient code

2010-09-17 Thread ubizjak at gmail dot com


--- 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|-00-00 00:00:00 |2010-09-17 09:59:36
   date||


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45685



[Bug rtl-optimization/45685] GCC optimizer for Intel x64 generates inefficient code

2010-09-17 Thread ubizjak at gmail dot com


--- Comment #5 from ubizjak at gmail dot com  2010-09-17 10:02 ---
Confirmed. Regression?


-- 

ubizjak at gmail dot com changed:

   What|Removed |Added

 Status|WAITING |NEW
 Ever Confirmed|0   |1
   Last reconfirmed|2010-09-17 09:59:36 |2010-09-17 10:02:53
   date||


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45685



[Bug rtl-optimization/45685] GCC optimizer for Intel x64 generates inefficient code

2010-09-16 Thread ekuznetsov at divxcorp dot com


--- Comment #3 from ekuznetsov at divxcorp dot com  2010-09-16 23:08 ---
Created an attachment (id=21813)
 -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21813action=view)
Output of gcc -v -O3 gcc-bug.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45685



[Bug rtl-optimization/45685] GCC optimizer for Intel x64 generates inefficient code

2010-09-15 Thread ekuznetsov at divxcorp dot com


--- Comment #1 from ekuznetsov at divxcorp dot com  2010-09-16 01:18 ---
Created an attachment (id=21807)
 -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21807action=view)
Sample code


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45685