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: Enable EBX for x86 in 32bits PIC code


2014-07-07 15:47 GMT+04:00 Jakub Jelinek <jakub@redhat.com>:
> On Mon, Jul 07, 2014 at 03:35:06PM +0400, Evgeny Stupachenko wrote:
>> The key problem here is that EBX is not used in register allocation.
>> If we relax the restriction on EBX the performance is back, but there
>> are several fails.
>> Some of them could be fixed.
>> However I don't like that way as EBX register is uninitialized at
>> register allocation.
>
> That is nothing wrong.  The magic registers are to be assumed live from the
> beginning until the prologue is emitted.

EBX does not need to be so magic. It is used to pass GOT pointer
according to ABI, so why not to make it a part of ABI?

We may use a target hook to identify if function has implicit input
parameter with GOT.  Then we handle this parameter in a regular way
and spill it to a virtual register with the only difference -
resulting RTL is written into PIC_OFFSET_TABLE_REGNUM.

In a similar way we may have implicit argument for calls and fill a
hard reg according to ABI from PIC_OFFSET_TABLE_REGNUM.

EBX would become a regular register then. If overall it looks
reasonable then I may try to make an experimental patch and check how
it affects performance.

Ilya

>
>> Initialization (SET_GOT) appeared only at: "217r.pro_and_epilogue" phase.
>>
>> The key point in 2 suggestions is to set EBX register only prior to a
>> call (as it is required by ABI). In all other cases it could be any
>> other register.
>
> You could use special call insn patterns for calls that need to have ebx
> set, where there would be a
> (use (match_operand:SI NN "register_operand" "b"))
> and pass in the lgot pseudo and leave the register allocator to do its job.
> You'd need to remember in which hard register (or memory) the register
> allocator wants lgot to be at the start of the first basic block (so that
> when prologue is expanded you know where to store it).
>
>         Jakub


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