I have the following very simple code that I would like to have vectorized by the compiler:
#include <cstdlib>
#include <cstdint>
static uint64_t HASH_MOD_PRIME = 8796093022151ull;
static uint64_t HASHED_POWERS_OF_BASE[32] =
{
5944711979223, 4888226268587, 1088871378212, 6368046812720,
5682482463725, 6980463874713, 4474597161960, 3050433740522,
4419504424015, 7686991881063, 4860352712696, 3954861113044,
100913750218, 7617674651447, 870392028436, 8144819954612,
5607682262899, 4298315880084, 8346575821400, 7352355788314,
2809282536675, 6913369912370, 5451192126612, 4805208003318,
5185419420497, 3389323909658, 3790747989636, 2405024174203,
7269509666190, 595217685378, 6309768715074, 3873446749003
};
static size_t Hash(const uint16_t* __restrict const data)
{
uint64_t result = 0;
for (int i = 0; i < 32; ++i)
{
result += data[i] * HASHED_POWERS_OF_BASE[i];
}
return result % HASH_MOD_PRIME;
}
int main()
{
uint16_t data[32];
return Hash(data);
}
yet it fails with loop not vectorized due to reason '1102'
. According to MS docs reason 1102
is Loop contains non-arithmetic or other non-vectorizable operations
.
Am I missing something or is this a compiler bug ?
See here: https://godbolt.org/z/TaovaxvxG