This is the mail archive of the gcc-patches@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: ifcvt/crossjump patch: Fix PR 42496, 21803


On 04/20/2010 12:05 AM, Eric Botcazou wrote:
>> Here's the second part.  This one should help most architectures, not
>> just the ones with conditional execution.  I've observed it helps on
>> i686 and arm, with the following being a typical result:
>>
>>  .L18:
>>         ldr     r1, [r2, #4]
>>         cmp     r1, #34
>> -       it      hi
>> -       ldrhi   r3, .L98+12
>> -       bhi     .L28
>>         ldr     r3, .L98+12
>> +       bhi     .L28
>>         ldrb    r2, [r3, #4]    @ zero_extendqisi2
>>         cbz     r2, .L29
>>         ldr     r3, [r3, #8]
> 
> I'm uncomfortable with this patch because I'm not sure it belongs in ifcvt.c.
> Conceptually it's a reversed form of cross jumping so it could be implemented 
> more generally in cfgcleanup.c.  And other transformations should already be 
> able to apply this kind of optimizations.  Do you have testcases?

When compiling a large collection of input files, it seems to trigger in
about 1/4 of them.  Here's a basic example:

int a, b, c, d;
int foo ()
{
  if (a)
    bar (b, c, d);
  else
    baz (b, c, d);
}

foo:				foo:
	pushl	%ebp			pushl	%ebp
	movl	%esp, %ebp		movl	%esp, %ebp
	subl	$24, %esp		subl	$24, %esp
	movl	a, %eax			movl	a, %eax
	testl	%eax, %eax		testl	%eax, %eax
	jne	.L6	      <
	movl	d, %eax			movl	d, %eax
	movl	%eax, 8(%esp)		movl	%eax, 8(%esp)
	movl	c, %eax			movl	c, %eax
	movl	%eax, 4(%esp)		movl	%eax, 4(%esp)
	movl	b, %eax			movl	b, %eax
	movl	%eax, (%esp)		movl	%eax, (%esp)
			      >		jne	.L6
	call	baz			call	baz
	leave				leave
	ret				ret
	.p2align 4,,7			.p2align 4,,7
	.p2align 3			.p2align 3
.L6:				.L6:
	movl	d, %eax	      |		.p2align 4,,8
	movl	%eax, 8(%esp) <
	movl	c, %eax	      <
	movl	%eax, 4(%esp) <
	movl	b, %eax	      <
	movl	%eax, (%esp)  <
	call	bar			call	bar
	leave				leave
			      >		.p2align 4,,7
	ret				ret


Bernd


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