On 2019-02-14 22:54 +0800, Colin Hercus wrote: > Hi, > > I have several functions using SIMD intrinsics with target specific > versions for SSE2, SSSE3, SSE4.1, AVX. They all use packed 8bit ints and > only 128bit data. > > As I'm using intrinsics, each version target is slightly different, SSSE3 > has _mm_shuffle_epi8, SSE4.1 has _mm_blendv_epi8. Because I need to use > only a few different intrinsics for each target the code is 95% > triplicated. Luckily the AVX code can be a target_clone of the SSE4.1 > version but the others are slightly different. > > Is it possible to have code conditional on the target like #ifdef > __TARGET_AVX2_ > that might let me have one source code with a few small conditional > segments? No. Because the preprocessor doesn't know what is "target attribute". > I tried using #ifdef __AVX__ which works if I select an AVX target on the > GCC command but doesn't work in a function with __attribute__ ((target > ("avx"))) I suggest to compile one source file with -msse3, -mavx, -mavx2, etc. to get multiple object files. -- Xi Ruoyao <xry111@xxxxxxxxxxxxxxxx> School of Aerospace Science and Technology, Xidian University