0

Is there any instruction for avx2 to load from memory through a look up table? For instance, I need to implement a function, this function has two variable int64_t a[256] and int lookuptable[256]. And I need to use avx2 assembly to load a through address in lookuptable. Like a[lookuptable[i]] in C language. Is there any instruction for this?

digito_evo
  • 3,216
  • 2
  • 14
  • 42
anna
  • 39
  • 3
  • 3
    A lookup is just a double load (one to look up the index, one to load from that index). I don't know if there exists an instruction that does that. I don't think so. But AVX has `vpgatherdq` and similar to do gathered loads. See [this](https://stackoverflow.com/questions/24756534/in-what-situation-would-the-avx2-gather-instructions-be-faster-than-individually). – Margaret Bloom Mar 20 '23 at 08:46
  • 2
    As @MargaretBloom says, with 64bit values and 32bit indexes, you need a `vpgatherdq` (with a scale of 8). Here is the documentation of that instruction: https://www.felixcloutier.com/x86/vpgatherdq:vpgatherqq – chtz Mar 20 '23 at 08:49

0 Answers0