On Mon, Jan 21, 2019 at 10:09:01AM +0100, Martin Liška wrote:
> @@ -11351,6 +11352,7 @@ match
> gfc_match_gcc_builtin (void)
> {
> char builtin[GFC_MAX_SYMBOL_LEN + 1];
> + char target[GFC_MAX_SYMBOL_LEN + 1];
>
> if (gfc_match (" ( %n ) attributes simd", builtin) != MATCH_YES)
> return MATCH_ERROR;
> @@ -11361,6 +11363,26 @@ gfc_match_gcc_builtin (void)
> else if (gfc_match (" ( inbranch ) ") == MATCH_YES)
> clause = SIMD_INBRANCH;
>
> + if (gfc_match (" if ( %n ) ", target) == MATCH_YES)
> + {
> + if (strcmp (target, "lp64") == 0)
> + {
> + if (TYPE_PRECISION (long_integer_type_node) != 64
> + || POINTER_SIZE != 64
> + || TYPE_PRECISION (integer_type_node) != 32)
> + return MATCH_YES;
> + }
> + else if (strcmp (target, "ilp32") == 0)
> + {
> + if (TYPE_PRECISION (long_integer_type_node) != 32
> + || POINTER_SIZE != 32
> + || TYPE_PRECISION (integer_type_node) != 32)
> + return MATCH_YES;
> + }
> + else
> + return MATCH_ERROR;
> + }
You should adjust the syntax above the function too.
And you need here buy-in from glibc folks.
> +
> if (gfc_vectorized_builtins == NULL)
> gfc_vectorized_builtins = new hash_map<nofree_string_hash, int> ();
>
> diff --git a/gcc/testsuite/gfortran.dg/simd-builtins-7.f90
> b/gcc/testsuite/gfortran.dg/simd-builtins-7.f90
> new file mode 100644
> index 00000000000..6445733d288
> --- /dev/null
> +++ b/gcc/testsuite/gfortran.dg/simd-builtins-7.f90
> @@ -0,0 +1,21 @@
> +! { dg-do compile { target { i?86-*-linux* x86_64-*-linux* } } }
> +! { dg-additional-options "-msse2 -mno-avx -nostdinc -Ofast
> -fpre-include=simd-builtins-7.h -fdump-tree-optimized" }
> +
> +program test_overloaded_intrinsic
> + real(4) :: x4(3200), y4(3200)
> + real(8) :: x8(3200), y8(3200)
> +
> + ! this should be using simd clone
> + y4 = sin(x4)
> + print *, y4
> +
> + ! this should not be using simd clone
The above 2 comments are misleading, they only match what ia32 does.
> + y4 = sin(x8)
> + print *, y8
> +end
> +
> +! { dg-final { scan-tree-dump "sinf.simdclone" "optimized" { target ia32 } }
> } */
> +! { dg-final { scan-tree-dump-not "sin.simdclone" "optimized" { target ia32
> } } } */
Perhaps use ilp32 instead of ia32?
Jakub