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: [patch i386]: Change stack probing and allocation implementation


2010/8/23 Richard Henderson <rth@redhat.com>:
> On 08/21/2010 08:23 AM, Kai Tietz wrote:
>> + ? ? addq ? ?$0x7, %rax ? ? ?/* Make sure stack is on alignment of 8. ?*/
>> + ? ? pushq ? %rcx ? ? ? ? ? ?/* save temp */
>> + ? ? andq ? ?$0xfffffffffffffff8, %rax
>
> Why the forced alignment? ?First, it's to the wrong alignment (8 vs 16).
> Second, I see no reason not to rely on the compiler passing a valid value.

Well, 8 is the natural alignment of stack. 16-bytes is just of
interest for x64, and the alloaction btw can be used to get aligned
stack at the end. So (size & 15) can be zero, or 8. But well, those
instructions shouldn't be necessary.

>> - ? ? ?if (m->fs.cfa_reg == stack_pointer_rtx)
>> - ? ? {
>> - ? ? ? m->fs.cfa_offset += allocate;
>> - ? ? ? t = gen_rtx_PLUS (Pmode, stack_pointer_rtx, GEN_INT (-allocate));
>> - ? ? ? t = gen_rtx_SET (VOIDmode, stack_pointer_rtx, t);
>> - ? ? ? add_reg_note (insn, REG_CFA_ADJUST_CFA, t);
>> - ? ? ? RTX_FRAME_RELATED_P (insn) = 1;
>> - ? ? }
>> - ? ? ?m->fs.sp_offset += allocate;
>> + ? ? ?pro_epilogue_adjust_stack (stack_pointer_rtx, stack_pointer_rtx,
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?GEN_INT (-allocate), -1,
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?m->fs.cfa_reg == stack_pointer_rtx);
>
> FWIW,
>
> ? ? ? ?subq ? ?%eax, %esp
>
> is going to be a smaller instruction than
>
> ? ? ? ?subq ? ?$large, %esp
>
> Is there a good reason not to use the known value of eax,
> and keep the existing REG_CFA_ADJUST_CFA note, but attach
> it to a different insn?
>
>> + ? ? ? ?emit_insn (gen_allocate_stack_worker_probe_32 (x, x));
>> + ? ? ?x = expand_simple_binop (Pmode, MINUS, stack_pointer_rtx, x,
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ?stack_pointer_rtx, 0, OPTAB_DIRECT);
>> + ? ? ?if (x != stack_pointer_rtx)
>> + ? ? emit_move_insn (stack_pointer_rtx, x);
>
> Likewise.

Well, I tried this first, but then the clobber instruction of stack
probing getting simply ignored. Therefore I use the result to avoid
hazzards.


Kai

-- 
|? (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination


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