assume attribute

You can use the assume attribute to make certain indications to the compiler so it can generate faster and more optimized code:

void limiter(float* data, size_t size) {
    [[assume(size > 0)]];
    [[assume(size % 32 == 0)]];

    for (size_t i = 0; i < size; ++i) {
        [[assume(std::isfinite(data[i])]];
        data[i] = std::clamp(data[i], -1.0f, 1.0f);
    }
}

A note is that the assumption is not evaluated or checked, so it’s your responsibility to ensure it’s always correct, if not: undefined behaviour (maybe throw an exception).

This way the compiler, when generate the code, can make certain assuptions and, if possible, generate better code according to them.

Source: https://www.sandordargo.com/blog/2022/12/14/cpp23-attributes