(_____(_____________(#)~~~~~~

  • 0 Posts
  • 5 Comments
Joined 3 years ago
cake
Cake day: April 11th, 2022

help-circle

  • Your 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;
    }