![](https://lemmygrad.ml/pictrs/image/3e0b895a-ef05-4ecd-aeb0-b32206f64764.png)
![](https://programming.dev/pictrs/image/170721ad-9010-470f-a4a4-ead95f51f13b.png)
13·
1 month agoYour CPU has big registers, so why not use them!
#include <x86intrin.h>
#include <stdio.h>
static int increment_one(int input)
{
int __attribute__((aligned(32))) result[8];
__m256i v = _mm256_set_epi32(0, 0, 0, 0, 0, 0, 1, input);
v = (__m256i)_mm256_hadd_ps((__m256)v, (__m256)v);
_mm256_store_si256((__m256i *)result, v);
return *result;
}
int main(void)
{
int input = 19;
printf("Input: %d, Incremented output: %d\n", input, increment_one(input));
return 0;
}
Unless your machine has error correcting memory. Then it will take literally forever.