Hard
The same loop over vectors of uint8_t and uint16_t
Both functions are compiled with Clang or GCC at -O2 for arm64, using libc++ or libstdc++. How does the generated code for the two loops differ?
main.cpp
#include <cstddef>
#include <cstdint>
#include <vector>
void scale8(std::vector<std::uint8_t>& v, std::uint8_t k) {
for (std::size_t i = 0; i < v.size(); ++i) v[i] *= k;
}
void scale16(std::vector<std::uint16_t>& v, std::uint16_t k) {
for (std::size_t i = 0; i < v.size(); ++i) v[i] *= k;
}40 of 44 in Compilers