On Tue, Aug 4, 2020 at 5:10 AM Jojo R <jiejie_r...@c-sky.com> wrote:
>
> Hi,
>
> Form My ABI, float register is used by function call,
> I want to pack float a and b into double v without any memory load/store,
>
> The flowing is my demo:
>
> Typedef union {
>         float ff[2];
>         double v;
> } double_u;
>
> Double pack_float (float a, float b) {
>
>         double_u tmp;
>
>         tmp.ff[0] = a;
>         tmp.ff[1] = b;
>
>         return tmp.v;
> }
>
> There is memory store in these statement:
>
> tmp.ff[0] = a;
> tmp.ff[1] = b;
>
> Could someone give me some hints to avoid memory load/store ?

Use inline assembly
(https://gcc.gnu.org/onlinedocs/gcc/Using-Assembly-Language-with-C.html)
because AFAIK, C/C++ cannot force its compiler to place a variable in
a register.

> Jojo

-- 
Best regards,
Tadeus

Reply via email to