On Thu, 3 Nov 2022 00:19:26 +0100 Bernhard Reutner-Fischer <rep.dot....@gmail.com> wrote:
> So target_clones is one thing. What other attributes would be important? > > doing something previously! (I don't know if I'll actually be able to > > work on it in the end, at least on work time.) > > heh, me neither. Luckily yesterday was a holiday, so what i ended up > with was the following, fya. > Consider: $ cat gcc/testsuite/gfortran.dg/attr_target_clones-1.F90; echo EOF ! { dg-require-ifunc "" } ! { dg-options "-O1" } ! { dg-additional-options "-fdump-tree-optimized" } ! It seems arch defines are not defined?! ! See fortran.cpp FIXME: Pandora's Box ! Ok, so enterprise-level bugfix: ! { dg-additional-options "-D__i386__=1" { target { i?86-*-* x86_64-*-* } } } ! { dg-additional-options "-D__powerpc__=1" { target { powerpc*-*-* } } } ! { dg-skip-if "test not yet implemented for target" { ! {i?86-*-* x86_64-*-* powerpc*-*-*} } } !! { dg- skip-if "needs optimize" { *-*-* } { "*" } { " -O0 " } } ! Test __attribute__ ((target_clones ("foo", "bar"))) ! module m implicit none contains subroutine sub1() #if defined __i386__ || defined __x86_64__ !GCC$ ATTRIBUTES target_clones("avx", "sse","default") :: sub1 #elif defined __powerpc__ !GCC$ ATTRIBUTES target_clones("power10", "power9","default") :: sub1 #endif print *, 4321 end end module m ! { dg-final { scan-tree-dump-times {(?n)void \* __m_MOD_sub1\.resolver \(\)} 1 "optimized" } } ! { dg-final { scan-tree-dump-times {(?n)void __m_MOD_sub1\.(?:avx|power10) \(\)} 1 "optimized" } } ! { dg-final { scan-tree-dump-times {(?n)void __m_MOD_sub1\.(?:sse|power9) \(\)} 1 "optimized" } } ! { dg-final { scan-tree-dump-times {(?n)void sub1 \(\)} 1 "optimized" } } !! and a non-assembly hint on the ifunc ! { dg-final { scan-tree-dump-times {Function sub1 \(__m_MOD_sub1\.default,} 1 "optimized" } } EOF 2 patches: https://gcc.gnu.org/pipermail/gcc-patches/2022-November/605081.html https://gcc.gnu.org/pipermail/gcc-patches/2022-November/604981.html (the testcase mentioned in the latter is superseded be the blurb above) One would have to cleanup the parser (see "XXX: Rephrase this in a sane, understandable manner..") and add some more testcases, for several malformed attribute strings. Maybe i'll get to it during the weekend or some evening. Not sure about the usefulness though. And not sure if fellow gfortraners would accept this attribute target_clones in there in the first place.. cheers,