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: -fuse-caller-save - Collect register usage information


> Let's look at the effect of the option (after the recent fix for PR61605) on
> gcc.target/i386/fuse-calller-save.c:
> ...
>   foo:
>   .LFB1:
>   	.cfi_startproc
> -	pushq	%rbx
> -	.cfi_def_cfa_offset 16
> -	.cfi_offset 3, -16
> -	movl	%edi, %ebx
>   	call	bar
> -	addl	%ebx, %eax
> -	popq	%rbx
> -	.cfi_def_cfa_offset 8
> +	addl	%edi, %eax
>   	ret
>   	.cfi_endproc
>   .LFE1:
> ...
> So, the effect is: instead of using a callee-save register, we use a
> caller-save register to store a value that's live over a call, without
> needing to add a caller-save, as would be normally the case.
> 
> If I see an option -foptimize-caller-saves, I'd expect the effect to be that
> without, there are some caller-saves and with, there are less. This is not
> the case in the diff above.

To me it is, "movl %edi, %ebx"/"addl %ebx, %eax" is a caller-save/restore.

> I'm starting to lean towards -foptimize-call-clobbers or similar.

Yes, that's also a good name and was my initial preference.  But you pointed 
out the existing -fcaller-saves:

`-fcaller-saves'
     Enable allocation of values to registers that are clobbered by
     function calls, by emitting extra instructions to save and restore
     the registers around such calls.  Such allocation is done only
     when it seems to result in better code.

so -foptimize-caller-saves can be understood as optimizing out the "extra 
instructions to save and restore  the registers around such calls" and, thus, 
as having a direct relationship with -fcaller-saves.

-- 
Eric Botcazou


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