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 ? thanks. Qing