On Thu, 25 Oct 2018 at 13:35, Martin Reinecke <martin@xxxxxxxxxxxxxxxxxxx> wrote: > > Hi Jonathan, > > thanks for the quick reply! > > > Macros are defined during preprocessing, and the preprocessor doesn't > > know anything about the target_clones attribute. When the compiler > > sees the attribute it can't go back in time and alter the result of > > earlier preprocessing. > > I feared as much. > This creates a nasty asymmetry in the sense that gcc's own optimizations > will be able to use all target features (because the compiler knows that > it is OK to use specific features like AVX instructions) whereas the > user has no way to hand-optimize where this becomes necessary. At least > not using this nice mechanism. They can, just not based on preprocessor macros. > > >> Is there a way to achieve what I have in mind? > > > > If you want three different implementations of the function I think > > you need three different clones. Or do runtime checks for the CPU > > features inside the function, but that seems suboptimal. > > I guess I'll just put all functions in question in a separate file and > compile this with different flags and name prefixes. > > Cheers, > Martin