llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.61k stars 11.82k forks source link

vectorization remark is printed multiple times #27992

Open llvmbot opened 8 years ago

llvmbot commented 8 years ago
Bugzilla Link 27618
Version 3.8
OS Linux
Reporter LLVM Bugzilla Contributor
CC @francisvm,@hfinkel

Extended Description

#define SIZE (1 << 15)

#define MINDEX(n, m) (SIZE*(n)+(m))

#define XMM_ALIGNMENT_BYTES 16

float *restrict mat_a __attribute__((aligned (XMM_ALIGNMENT_BYTES)));
float *restrict vec_b __attribute__((aligned (XMM_ALIGNMENT_BYTES)));
float *restrict vec_c __attribute__((aligned (XMM_ALIGNMENT_BYTES)));

// __attribute__ ((noinline))
void matvec_autovec()
{
    int i, j;

    float tmp;
    for (i = 0; i < SIZE; i++) {
        tmp = 0;
        for (j = 0; j < SIZE; j++) {
            tmp += mat_a[MINDEX(i, j)] * vec_b[j];
        }
        vec_c[i] = tmp;
    }
}

void multiple()
{
    matvec_autovec();
}

int main(int argc, char **argv)
{
    return 0;
}

The command I used is clang-3.8 -Ofast test.c -Rpass=loop-vectorize

test.c:22:9: remark: vectorized loop (vectorization width: 4, interleaved count: 1) [-Rpass=loop-vectorize]
        for (j = 0; j < SIZE; j++) {
        ^
test.c:22:9: remark: vectorized loop (vectorization width: 4, interleaved count: 1) [-Rpass=loop-vectorize]

The output reduces to 1 after I uncomment the noinline attribute.

hfinkel commented 8 years ago

Indeed, I think we need to provide more information when the remark occurs in the context of inlined code.