This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Inner-loop optimization regression from 3.3 to 3.4


"Zack Weinberg" <zack@codesourcery.com> writes:

> I wanted a break from machine modes so I thought I'd squeeze some
> cycles out of _cpp_skip_block_comment.  In the process I discovered
> a serious optimization regression in 3.4, relative to 3.3.

I have now discovered that writing instead

  for (;;)
    {
      c = *cur++;

      if (c == '/')
        {
          if (cur[-2] == '*'
            break;
        
          foo();
        }
      else if (c == '\n')
        bar();
   }

-- the same thing but without the inner do-while -- generates much
better code:

.L350:
	incl	%ebx
	cmpb	$47, %al
	je	.L352
	.p2align 4,,15
.L339:
	cmpb	$10, %al
	je	.L353
.L346:
	movzbl	(%ebx), %eax
.L354:
	incl	%ebx
	cmpb	$47, %al
	jne	.L339

No redundant comparisons and mucking around with setcc, and it's even
managed to rotate the loop so there's only two branches.

So I'm going to check in the code like this; if you want to see the
problem as it was, just put back the do-while.

zw


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]