Why does different types of array subscript used to iterate affect auto vectorization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 Hi all,

Recently, I met an issue with auto vectorization.

As following code shows, why uint32_t prevents the compiler (GCC 12.1 + O3)
from optimizing by auto vectorization. See https://godbolt.org/z/a3GfaKEq6.

#include <cstdint>

// no auto vectorization
void test32(uint32_t *array, uint32_t &nread, uint32_t from, uint32_t to) {
    for (uint32_t i = from; i < to; i++) {
        array[nread++] = i;
    }
}

// auto vectorization
void test64(uint32_t *array, uint64_t &nread, uint32_t from, uint32_t to) {
    for (uint32_t i = from; i < to; i++) {
        array[nread++] = i;
    }
}

// no auto vectorization
void test_another_32(uint32_t *array, uint32_t &nread, uint32_t from,
uint32_t to) {
    uint32_t index = nread;
    for (uint32_t i = from; i < to; i++) {
        array[index++] = i;
    }
    nread = index;
}

// auto vectorization
void test_another_64(uint32_t *array, uint32_t &nread, uint32_t from,
uint32_t to) {
    uint64_t index = nread;
    for (uint32_t i = from; i < to; i++) {
        array[index++] = i;
    }
    nread = index;
}

After I ran the command g++ -O3 -fopt-info-vec-missed -c test.cc -o
/dev/null, I got the following result. How to interpret it?

bash> g++ -O3 -fopt-info-vec-missed -c test.cc -o /dev/null
test.cc:5:31: missed: couldn't vectorize loop
test.cc:6:24: missed: not vectorized: not suitable for scatter store *_5 =
i_18;
test.cc:21:31: missed: couldn't vectorize loop
test.cc:22:24: missed: not vectorized: not suitable for scatter store *_4 =
i_22;

-- 
Best regards,
Adonis



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux