[PATCH][middle-end][i386][version 3]Add -fzero-call-used-regs=[skip|used-gpr-arg|used-arg|all-arg|used-gpr|all-gpr|used|all]

Qing Zhao QING.ZHAO@ORACLE.COM
Thu Oct 22 16:37:47 GMT 2020



> On Oct 22, 2020, at 10:34 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
> 
> On Thu, Oct 22, 2020 at 4:47 PM Qing Zhao <QING.ZHAO@oracle.com <mailto:QING.ZHAO@oracle.com>> wrote:
>> 
>> Hi, Uros,
>> 
>>> On Oct 21, 2020, at 9:45 AM, Qing Zhao via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
>>>>>> 
>>>> 
>>>> Something like this:
>>>> 
>>>> --cut here--
>>>> long double
>>>> __attribute__ ((noinline))
>>>> test (long double a, long double b)
>>>> {
>>>> long double r = a + b;
>>>> 
>>>> asm volatile ("fldz;                \
>>>>      fldz;                \
>>>>      fldz;                \
>>>>      fldz;                \
>>>>      fldz;                \
>>>>      fldz;                \
>>>>      fldz;                \
>>>>      fstp %%st(0);            \
>>>>      fstp %%st(0);            \
>>>>      fstp %%st(0);            \
>>>>      fstp %%st(0);            \
>>>>      fstp %%st(0);            \
>>>>      fstp %%st(0);            \
>>>>      fstp %%st(0)" : : "X"(r));
>>>> return r;
>>>> }
>>>> 
>>>> int
>>>> main ()
>>>> {
>>>> long double a = 1.1, b = 1.2;
>>>> 
>>>> long double c = test (a, b);
>>>> 
>>>> printf ("%Lf\n", c);
>>>> 
>>>> return 0;
>>>> }
>>>> --cut here—
>>> 
>>> 
>>> Okay, so,
>>> 
>>> 1. First compute how many st registers need to be zeroed,  num_of_zeroed_st
>>> 2. Then issue (8 - num_of_zeroed_st) fldz to push 0 to the stack to clear all the dead stack slots;
>>> 3. Then issue (8 - num_of_zeroed_st) fstp %st(0) to pop the stack and empty the stack.
>>> 
>> 
>> How to generate such asm volatile insn at i386 backend? Is there any code in i386 backend I can refer for this ?
> 
> fldz is plain move of zero to XF register, fstp is generated from an
> XF move of FIRST_STACK_REG to itself with REG_DEAD note added:
> 
> #(insn 366 128 129 9 (set (reg:XF 8 st)
> #        (reg:XF 8 st)) "test.c":711:14 110 {*movxf_internal}
> #     (expr_list:REG_DEAD (reg:XF 8 st)
> #        (nil)))

What’s the reason to add the “REG_DEAD” note?

Qing
> 
> Uros.



More information about the Gcc-patches mailing list