[llvm-dev] how to force llvm generate gather intrinsic

zhi chen via llvm-dev llvm-dev at lists.llvm.org
Fri Jan 22 16:00:31 PST 2016


Hi,

I used clang -O3 -c -emit-llvm on the follow code to generate a bitcode,
say a.bc. I read the .ll file and didn't see any gather intrinsic. Also, I
used opt -O3 -mcpu=core-avx2/-mcpu=skx, but there is still no gather
intrinsic generated.

int foo(int A[800], int B[800], int C[800]) {
    for (int i = 0; i < 800; i++) {
        A[B[i]] = i + 5;
    }

    for (int i = 0; i < 800; i++) {
        A[B[i]]++;
    }

    for (int i = 0; i < 800; i++) {
        A[i] = B[C[i]];
    }
    return 0;
}

Could some give me an example that will generate gather intrinsic for AVX2?
I tried to used the masked_gather intrinsic provided in the language ref.
But it seemed that it only generates gather intrinsic for AVX-512 but for
AVX-2. I found that there are 16 gather intrinsic versions depending on the
data types provided for AVX-2. Do I have to check the data type before
calling them specifically? or is there a generic way to use AVX-2 gather
intrinsic?

Best,
Zhi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160122/32911e71/attachment.html>


More information about the llvm-dev mailing list