On April 10, 2018 3:06:55 PM GMT+02:00, Jakub Jelinek <ja...@redhat.com> wrote: >On Tue, Apr 10, 2018 at 02:55:43PM +0200, Richard Biener wrote: >> > And the easiest solution is in the Fortran FE based on some flag >> > (e.g. -mveclibabi=glibc) through a target hook add >> > __attribute__((__simd__ ("notinbranch"))) >> > to the builtins like __builtin_sin etc. that have them in the >> > glibc header (x86_64 -m64 and -ffast-math only): >> > >> > # undef __DECL_SIMD_cos >> > # define __DECL_SIMD_cos __DECL_SIMD_x86_64 >> > # undef __DECL_SIMD_cosf >> > # define __DECL_SIMD_cosf __DECL_SIMD_x86_64 >> > # undef __DECL_SIMD_sin >> > # define __DECL_SIMD_sin __DECL_SIMD_x86_64 >> > # undef __DECL_SIMD_sinf >> > # define __DECL_SIMD_sinf __DECL_SIMD_x86_64 >> > # undef __DECL_SIMD_sincos >> > # define __DECL_SIMD_sincos __DECL_SIMD_x86_64 >> > # undef __DECL_SIMD_sincosf >> > # define __DECL_SIMD_sincosf __DECL_SIMD_x86_64 >> > # undef __DECL_SIMD_log >> > # define __DECL_SIMD_log __DECL_SIMD_x86_64 >> > # undef __DECL_SIMD_logf >> > # define __DECL_SIMD_logf __DECL_SIMD_x86_64 >> > # undef __DECL_SIMD_exp >> > # define __DECL_SIMD_exp __DECL_SIMD_x86_64 >> > # undef __DECL_SIMD_expf >> > # define __DECL_SIMD_expf __DECL_SIMD_x86_64 >> > # undef __DECL_SIMD_pow >> > # define __DECL_SIMD_pow __DECL_SIMD_x86_64 >> > # undef __DECL_SIMD_powf >> > # define __DECL_SIMD_powf __DECL_SIMD_x86_64 >> > >> > The sincos/sincosf stuff is questionable, because some glibc >versions >> > implement it incorrectly and the simd ("notinbranch") attribute >isn't that >> > useful for it anyway, we'd want to use extra clauses so that it >doesn't need >> > to do scatter stores. >> >> I wonder if it is possible for glibc to ship a "module" for fortran >instead >> containing the appropriate declarations and gfortran auto-include >that >> (if present). > >Then we'd run into module binary format changing every release, so hard >for >glibc to ship that.
It's just nobody bothered to implement version dependent parsing (it's plain text after all). >Another thing is how would we express it in the module, >we could just use OpenMP syntax, > interface > function sin(x) bind(C,name="__builtin_sin") result(res) > import > !$omp declare simd notinbranch > real(c_double) :: res > real(c_double),value :: x > end function > end interface >but we'd need to temporarily enable OpenMP while parsing that module. >I see Fortran now supports already >!GCC$ attributes stdcall, fastcall::test >Could we support >!GCC$ attributes simd >and >!GCC$ attributes simd('notinbranch') >too? I guess that would be useful indeed. Richard. > Jakub