geza
geza

Reputation: 30020

Why does -fno-signed-zeros have an effect on vectorization for minimum search?

See this simple minimum search (Godbolt):

float foo(const float *data, int n) {
    float v = data[0];
    for (int i = 1; i < n; i++) {
        float d = data[i];
        if (d < v) {
            v = d;
        }
    }
    return v;
}

Neither gcc nor clang auto-vectorizes this code with -O3. If I use -ffinite-math-only, still no auto-vectorization happen. I need to use -ffinite-math-only and -fno-signed-zeros and the compiler auto-vectorizes the code. Why is -fno-signed-zeros needed for auto-vectorization to kick in?

Upvotes: 2

Views: 169

Answers (0)

Related Questions