This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to get 4 values from a table once ?

hi, guys:

let me set an example:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

int table[256]={......};

int lookup_tbl(int index)

{

   return table[index];

}

int main()

{

   int idx0, idx1, idx2, idx3;

   int tbl0, tbl1, tbl2, tbl3;

   idx0 = 2;

   idx1 = 36;

   idx2 = 111;

   idx3 = 204;

    tbl0 = lookup_tbl(idx0);

    tbl1 = lookup_tbl(idx1);

    tbl2 = lookup_tbl(idx2);

    tbl3 = lookup_tbl(idx3);

}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

my question is:

Could I use some neon intrinsic(maybe VTBL) to get the 4 values once? if I have set the index into a 32x4_t variable ?

thank you very much.

Parents
  • Hi,

    Yes, NEON instructions can be useful for loading multiple values at once but they can't be used to achieve what you are trying to do. From what I can see, you are trying to load four essentially arbitrary elements from an array (in your example, elements 2, 36, 111 and 204). NEON load instructions can load 4 32-bit values in a single operation but they have to be contiguous elements (there are some variations here which use the structured load instructions to de-interleave structured data but they still operate on contiguous elements in memory).

    For instance:

      int32x4_t temp;

      temp = vld1q_s32(table);

    compiles to:

      LDR r0, =table

      VLD1.32 {d0,d1}, [r0]

    This loads 4 consecutive 32-bit words from the table. But I'm afraid they do have to be consecutive.

    Chris

Reply
  • Hi,

    Yes, NEON instructions can be useful for loading multiple values at once but they can't be used to achieve what you are trying to do. From what I can see, you are trying to load four essentially arbitrary elements from an array (in your example, elements 2, 36, 111 and 204). NEON load instructions can load 4 32-bit values in a single operation but they have to be contiguous elements (there are some variations here which use the structured load instructions to de-interleave structured data but they still operate on contiguous elements in memory).

    For instance:

      int32x4_t temp;

      temp = vld1q_s32(table);

    compiles to:

      LDR r0, =table

      VLD1.32 {d0,d1}, [r0]

    This loads 4 consecutive 32-bit words from the table. But I'm afraid they do have to be consecutive.

    Chris

Children
No data