I’m trying to concatenate two uint32_t and get back a uint64_t. Here’s my method
uint64_t concat_int1_int2 (uint32_t int1, uint32_t int2) {
uint64_t concatenated = int1;
return concatenated << 32 | int2;
}
This seems to be extremely slow (I need to do it ~1,000,000 times and it is taking ~ 6 minutes). Two questions, why does the bit shift take so long (that seems to be the limiting step), and does anyone have a suggestion for a faster way to do this?
The way you are doing it is correct. It may help to
inlinethe function. Most likely your performance problem is in code you haven’t shown us.