From: "Martin Liška" <mliska@suse.cz>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>,
Richard Biener <richard.guenther@gmail.com>,
"fortran@gcc.gnu.org" <fortran@gcc.gnu.org>,
Thomas Koenig <tkoenig@netcologne.de>,
Toon Moene <toon@moene.org>,
GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Support simd function declarations via a pre-include.
Date: Mon, 19 Nov 2018 12:16:00 -0000 [thread overview]
Message-ID: <f135e1be-4c90-aff5-e863-1f5bcf06fa44@suse.cz> (raw)
In-Reply-To: <9979fb3e-f010-a48a-8ab7-55017d2d4c81@suse.cz>
[-- Attachment #1: Type: text/plain, Size: 3949 bytes --]
On 11/16/18 4:12 PM, Martin Liška wrote:
> On 11/16/18 2:49 PM, Jakub Jelinek wrote:
>> On Fri, Nov 16, 2018 at 02:24:42PM +0100, Martin Liška wrote:
>>> + if (gfc_match (" (%n) attributes simd", builtin) != MATCH_YES)
>>> + return MATCH_ERROR;
>>> +
>>> + int builtin_kind = 0;
>>> + if (gfc_match (" (notinbranch)") == MATCH_YES)
>>
>> I think you need " ( notinbranch )" here.
>>
>>> + builtin_kind = -1;
>>> + else if (gfc_match (" (inbranch)") == MATCH_YES)
>>> + builtin_kind = 1;
>>
>> And similarly here (+ testsuite coverage for whether you can in free form
>> insert spaces in all the spots that should be allowed).
>> !gcc$ builtin ( sinf ) attributes simd ( notinbranch ) ! comment
>> e.g. should be valid in free form (and fixed form too).
>>
>>> --- a/gcc/fortran/gfortran.h
>>> +++ b/gcc/fortran/gfortran.h
>>> @@ -2764,6 +2764,18 @@ bool gfc_in_match_data (void);
>>> match gfc_match_char_spec (gfc_typespec *);
>>> extern int directive_unroll;
>>>
>>> +/* Tuple for parsing of vectorized built-ins. */
>>> +struct vect_builtin_tuple
>>> +{
>>> + vect_builtin_tuple (const char *n, int t): name (n), simd_type (t)
>>
>> gfc_vect_builtin_tuple ?
>> + document what the simd_type is (or make it enum or whatever).
>> One option would be enum omp_clause_code and use OMP_CLAUSE_ERROR for
>> the case where the argument isn't specified, but I think generally
>> gfortran.h doesn't depend on tree* stuff and wants to have its own
>> enums etc.
>>
>>> +extern vec<vect_builtin_tuple> vectorized_builtins;
>>
>> gfc_vectorized_builtins ?
>>
>>> --- a/gcc/fortran/trans-intrinsic.c
>>> +++ b/gcc/fortran/trans-intrinsic.c
>>> @@ -597,7 +597,61 @@ define_quad_builtin (const char *name, tree type, bool is_const)
>>> return fndecl;
>>> }
>>>
>>> +/* Add SIMD attribute for FNDECL built-in if the built-in
>>> + name is in VECTORIZED_BUILTINS. */
>>> +#include "print-tree.h"
>>
>> If you need to include a header, include it at the start of the file.
>>
>>> +static void
>>> +add_simd_flag_for_built_in (tree fndecl)
>>> +{
>>> + if (fndecl == NULL_TREE)
>>> + return;
>>> +
>>> + const char *name = IDENTIFIER_POINTER (DECL_NAME (fndecl));
>>> + for (unsigned i = 0; i < vectorized_builtins.length (); i++)
>>> + if (strcmp (vectorized_builtins[i].name, name) == 0)
>>
>> How many add_simd_flag_for_built_in calls are we expecting and how many
>> vectorized_builtins.length ()? If it is too much, perhaps e.g. sort
>> the vector by name and do a binary search. At least if it turns out to be
>> non-trivial compile time.
>>> +
>>> + vectorized_builtins.truncate (0);
>>
>> That is a memory leak, right? The names are malloced.
>> And why truncate rather than release?
>>> + const char *path = find_a_file (&include_prefixes, argv[1], R_OK, true);
>>> + if (path != NULL)
>>> + return concat (argv[0], path, NULL);
>>
>> Formatting.
>>> --- /dev/null
>>> +++ b/gcc/testsuite/gfortran.dg/simd-builtins-1.h
>>> @@ -0,0 +1,4 @@
>>> +!GCC$ builtin (sinf) attributes simd
>>> +!GCC$ builtin (sinf) attributes simd (inbranch)
>>> +!GCC$ builtin (sinf) attributes simd (notinbranch)
>>> +!GCC$ builtin (cosf) attributes simd (notinbranch)
>>
>> Are you sure it is a good idea to have the 3 first lines for the same
>> builtin, rather than different?
>>
>> It should be testsuite covered what we do in that case, but with the above
>> you don't cover what happens e.g. with notinbranch alone, or no argument.
>>
>> Plus, as I said, I think you should have one *.f and one *.f90 test where
>> you just use many of those !gcc$ builtin lines with spaces in various spots
>> to verify it is parsed properly.
>>
>> Jakub
>>
>
> Hi.
>
> I'm sending version, I changed the container to hash_map that should provide
> faster look up.
>
> I've been testing the patch right now.
>
> Martin
>
Hi.
I'm sending one another tested version on x86_64-linux-gnu. I fixed issues spotted
by Jakub.
Martin
[-- Attachment #2: 0001-Support-simd-function-declarations-via-a-pre-include.patch --]
[-- Type: text/x-patch, Size: 19479 bytes --]
From 0d39d1dc7067849cec0fbd35382bb18f98ed29ba Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Wed, 7 Nov 2018 12:41:19 +0100
Subject: [PATCH] Support simd function declarations via a pre-include.
gcc/ChangeLog:
2018-11-15 Martin Liska <mliska@suse.cz>
* config/gnu-user.h (TARGET_F951_OPTIONS): New.
* gcc.c (find_fortran_preinclude_file): New function
to handle Fortran pre-include.
gcc/fortran/ChangeLog:
2018-11-15 Martin Liska <mliska@suse.cz>
* decl.c (gfc_match_gcc_builtin): New function.
* gfortran.h (struct vect_builtin_tuple): New.
(gfc_adjust_builtins): Likewise.
* lang-specs.h (TARGET_F951_OPTIONS): New.
(F951_OPTIONS): Use it.
* lang.opt: Add new option -fpre-include.
* match.h (gfc_match_gcc_builtin): Declare new function.
* parse.c (decode_gcc_attribute): Handle builtin.
(parse_progunit): Call gfc_adjust_builtins.
* scanner.c (gfc_new_file): Load pre-included header file
when provided.
* trans-intrinsic.c (add_simd_flag_for_built_in): New.
(gfc_adjust_builtins): Likewise.
gcc/testsuite/ChangeLog:
2018-11-15 Martin Liska <mliska@suse.cz>
* gfortran.dg/simd-builtins-1.f90: New test.
* gfortran.dg/simd-builtins-1.h: New test.
* gfortran.dg/simd-builtins-2.f90: New test.
* gfortran.dg/simd-builtins-3.f90: New test.
* gfortran.dg/simd-builtins-3.h: New test.
* gfortran.dg/simd-builtins-4.f: New test.
* gfortran.dg/simd-builtins-4.h: New test.
* gfortran.dg/simd-builtins-5.f: New test.
* gfortran.dg/simd-builtins-6.f90: New test.
---
gcc/config/gnu-user.h | 4 ++
gcc/fortran/decl.c | 41 +++++++++++
gcc/fortran/gfortran.h | 22 ++++++
gcc/fortran/lang-specs.h | 10 ++-
gcc/fortran/lang.opt | 4 ++
gcc/fortran/match.h | 1 +
gcc/fortran/parse.c | 3 +
gcc/fortran/scanner.c | 4 ++
gcc/fortran/trans-intrinsic.c | 70 +++++++++++++++++++
gcc/gcc.c | 19 +++++
gcc/testsuite/gfortran.dg/simd-builtins-1.f90 | 19 +++++
gcc/testsuite/gfortran.dg/simd-builtins-1.h | 4 ++
gcc/testsuite/gfortran.dg/simd-builtins-2.f90 | 20 ++++++
gcc/testsuite/gfortran.dg/simd-builtins-3.f90 | 1 +
gcc/testsuite/gfortran.dg/simd-builtins-3.h | 8 +++
gcc/testsuite/gfortran.dg/simd-builtins-4.f | 1 +
gcc/testsuite/gfortran.dg/simd-builtins-4.h | 8 +++
gcc/testsuite/gfortran.dg/simd-builtins-5.f | 9 +++
gcc/testsuite/gfortran.dg/simd-builtins-6.f90 | 24 +++++++
19 files changed, 270 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/gfortran.dg/simd-builtins-1.f90
create mode 100644 gcc/testsuite/gfortran.dg/simd-builtins-1.h
create mode 100644 gcc/testsuite/gfortran.dg/simd-builtins-2.f90
create mode 100644 gcc/testsuite/gfortran.dg/simd-builtins-3.f90
create mode 100644 gcc/testsuite/gfortran.dg/simd-builtins-3.h
create mode 100644 gcc/testsuite/gfortran.dg/simd-builtins-4.f
create mode 100644 gcc/testsuite/gfortran.dg/simd-builtins-4.h
create mode 100644 gcc/testsuite/gfortran.dg/simd-builtins-5.f
create mode 100644 gcc/testsuite/gfortran.dg/simd-builtins-6.f90
diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h
index 5b48fb21514..d0acfed5116 100644
--- a/gcc/config/gnu-user.h
+++ b/gcc/config/gnu-user.h
@@ -170,3 +170,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
LD_STATIC_OPTION " --whole-archive -llsan --no-whole-archive " \
LD_DYNAMIC_OPTION "}}%{!static-liblsan:-llsan}"
#endif
+
+#undef TARGET_F951_OPTIONS
+#define TARGET_F951_OPTIONS "%{!nostdinc:\
+ %:fortran-preinclude-file(-fpre-include= math-vector-fortran.h)}"
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 2b77d950abb..ac8679886af 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -98,6 +98,9 @@ bool gfc_matching_function;
/* Set upon parsing a !GCC$ unroll n directive for use in the next loop. */
int directive_unroll = -1;
+/* Map of middle-end built-ins that should be vectorized. */
+hash_map<nofree_string_hash, int> *gfc_vectorized_builtins;
+
/* If a kind expression of a component of a parameterized derived type is
parameterized, temporarily store the expression here. */
static gfc_expr *saved_kind_expr = NULL;
@@ -11243,3 +11246,41 @@ gfc_match_gcc_unroll (void)
gfc_error ("Syntax error in !GCC$ UNROLL directive at %C");
return MATCH_ERROR;
}
+
+/* Match a !GCC$ builtin (b) attributes simd flags form:
+
+ The parameter b is name of a middle-end built-in.
+ Flags are one of:
+ - (empty)
+ - inbranch
+ - notinbranch
+
+ When we come here, we have already matched the !GCC$ builtin string. */
+match
+gfc_match_gcc_builtin (void)
+{
+ char builtin[GFC_MAX_SYMBOL_LEN + 1];
+
+ if (gfc_match (" ( %n ) attributes simd", builtin) != MATCH_YES)
+ return MATCH_ERROR;
+
+ gfc_simd_clause clause = SIMD_NONE;
+ if (gfc_match (" ( notinbranch ) ") == MATCH_YES)
+ clause = SIMD_NOTINBRANCH;
+ else if (gfc_match (" ( inbranch ) ") == MATCH_YES)
+ clause = SIMD_INBRANCH;
+
+ if (gfc_vectorized_builtins == NULL)
+ gfc_vectorized_builtins = new hash_map<nofree_string_hash, int> ();
+
+ char *r = XNEWVEC (char, strlen (builtin) + 32);
+ sprintf (r, "__builtin_%s", builtin);
+
+ bool existed;
+ int &value = gfc_vectorized_builtins->get_or_insert (r, &existed);
+ value |= clause;
+ if (existed)
+ free (r);
+
+ return MATCH_YES;
+}
diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index d8ef35d9d6c..9248685a271 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -2764,6 +2764,27 @@ bool gfc_in_match_data (void);
match gfc_match_char_spec (gfc_typespec *);
extern int directive_unroll;
+/* SIMD clause enum. */
+enum gfc_simd_clause
+{
+ SIMD_NONE = (1 << 0),
+ SIMD_INBRANCH = (1 << 1),
+ SIMD_NOTINBRANCH = (1 << 2)
+};
+
+/* Tuple for parsing of vectorized built-ins. */
+struct gfc_vect_builtin_tuple
+{
+ gfc_vect_builtin_tuple (const char *n, gfc_simd_clause t)
+ : name (n), simd_type (t) {}
+
+ const char *name;
+ gfc_simd_clause simd_type;
+};
+
+/* Map of middle-end built-ins that should be vectorized. */
+extern hash_map<nofree_string_hash, int> *gfc_vectorized_builtins;
+
/* Handling Parameterized Derived Types */
bool gfc_insert_kind_parameter_exprs (gfc_expr *);
bool gfc_insert_parameter_exprs (gfc_expr *, gfc_actual_arglist *);
@@ -3501,5 +3522,6 @@ bool gfc_is_reallocatable_lhs (gfc_expr *);
/* trans-decl.c */
void finish_oacc_declare (gfc_namespace *, gfc_symbol *, bool);
+void gfc_adjust_builtins (void);
#endif /* GCC_GFORTRAN_H */
diff --git a/gcc/fortran/lang-specs.h b/gcc/fortran/lang-specs.h
index c3ab9700ea7..61a9118d531 100644
--- a/gcc/fortran/lang-specs.h
+++ b/gcc/fortran/lang-specs.h
@@ -32,9 +32,15 @@
#define F951_CPP_OPTIONS "%{!nocpp: -cpp=%g.f90 %{E} %(cpp_unique_options) \
%{E|M|MM:%(cpp_debug_options) " CPP_ONLY_OPTIONS \
" -fsyntax-only};: " CPP_FORWARD_OPTIONS "}"
+
+#ifndef TARGET_F951_OPTIONS
+#define TARGET_F951_OPTIONS
+#endif
+
#define F951_OPTIONS "%(cc1_options) %{J*} \
- %{!nostdinc:-fintrinsic-modules-path finclude%s}\
- %{!fsyntax-only:%(invoke_as)}"
+ %{!nostdinc:-fintrinsic-modules-path finclude%s}" \
+ TARGET_F951_OPTIONS \
+ "%{!fsyntax-only:%(invoke_as)}"
#define F951_SOURCE_FORM "%{!ffree-form:-ffixed-form}"
diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
index 2b7f2903761..c86b2623fac 100644
--- a/gcc/fortran/lang.opt
+++ b/gcc/fortran/lang.opt
@@ -662,6 +662,10 @@ fprotect-parens
Fortran Var(flag_protect_parens) Init(-1)
Protect parentheses in expressions.
+fpre-include=
+Fortran RejectNegative Joined Var(flag_pre_include) Undocumented
+Path to header file that should be pre-included before each compilation unit.
+
frange-check
Fortran Var(flag_range_check) Init(1)
Enable range checking during compilation.
diff --git a/gcc/fortran/match.h b/gcc/fortran/match.h
index 418542bd5a6..f25ed860c06 100644
--- a/gcc/fortran/match.h
+++ b/gcc/fortran/match.h
@@ -247,6 +247,7 @@ match gfc_match_dimension (void);
match gfc_match_external (void);
match gfc_match_gcc_attributes (void);
match gfc_match_gcc_unroll (void);
+match gfc_match_gcc_builtin (void);
match gfc_match_import (void);
match gfc_match_intent (void);
match gfc_match_intrinsic (void);
diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c
index 13cc6f5fccd..56d0d050bc3 100644
--- a/gcc/fortran/parse.c
+++ b/gcc/fortran/parse.c
@@ -1072,6 +1072,7 @@ decode_gcc_attribute (void)
match ("attributes", gfc_match_gcc_attributes, ST_ATTR_DECL);
match ("unroll", gfc_match_gcc_unroll, ST_NONE);
+ match ("builtin", gfc_match_gcc_builtin, ST_NONE);
/* All else has failed, so give up. See if any of the matchers has
stored an error message of some sort. */
@@ -5663,6 +5664,8 @@ parse_progunit (gfc_statement st)
gfc_state_data *p;
int n;
+ gfc_adjust_builtins ();
+
if (gfc_new_block
&& gfc_new_block->abr_modproc_decl
&& gfc_new_block->attr.function)
diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c
index 55d6dafdb5d..4e500f88174 100644
--- a/gcc/fortran/scanner.c
+++ b/gcc/fortran/scanner.c
@@ -2428,6 +2428,10 @@ gfc_new_file (void)
{
bool result;
+ if (flag_pre_include != NULL
+ && !load_file (flag_pre_include, NULL, false))
+ exit (FATAL_EXIT_CODE);
+
if (gfc_cpp_enabled ())
{
result = gfc_cpp_preprocess (gfc_source_file);
diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c
index 4ae2b3252b5..40a74916bb8 100644
--- a/gcc/fortran/trans-intrinsic.c
+++ b/gcc/fortran/trans-intrinsic.c
@@ -597,7 +597,77 @@ define_quad_builtin (const char *name, tree type, bool is_const)
return fndecl;
}
+/* Add SIMD attribute for FNDECL built-in if the built-in
+ name is in VECTORIZED_BUILTINS. */
+static void
+add_simd_flag_for_built_in (tree fndecl)
+{
+ if (gfc_vectorized_builtins == NULL
+ || fndecl == NULL_TREE)
+ return;
+
+ const char *name = IDENTIFIER_POINTER (DECL_NAME (fndecl));
+ int *clauses = gfc_vectorized_builtins->get (name);
+ if (clauses)
+ {
+ for (unsigned i = 0; i < 3; i++)
+ if (*clauses & (1 << i))
+ {
+ gfc_simd_clause simd_type = (gfc_simd_clause)*clauses;
+ tree omp_clause = NULL_TREE;
+ if (simd_type == SIMD_NONE)
+ ; /* No SIMD clause. */
+ else
+ {
+ omp_clause_code code
+ = (simd_type == SIMD_INBRANCH
+ ? OMP_CLAUSE_INBRANCH : OMP_CLAUSE_NOTINBRANCH);
+ omp_clause = build_omp_clause (UNKNOWN_LOCATION, code);
+ omp_clause = build_tree_list (NULL_TREE, omp_clause);
+ }
+
+ DECL_ATTRIBUTES (fndecl)
+ = tree_cons (get_identifier ("omp declare simd"), omp_clause,
+ DECL_ATTRIBUTES (fndecl));
+ }
+ }
+}
+
+ /* Set SIMD attribute to all built-in functions that are mentioned
+ in gfc_vectorized_builtins vector. */
+
+void
+gfc_adjust_builtins (void)
+{
+ gfc_intrinsic_map_t *m;
+ for (m = gfc_intrinsic_map;
+ m->id != GFC_ISYM_NONE || m->double_built_in != END_BUILTINS; m++)
+ {
+ add_simd_flag_for_built_in (m->real4_decl);
+ add_simd_flag_for_built_in (m->complex4_decl);
+ add_simd_flag_for_built_in (m->real8_decl);
+ add_simd_flag_for_built_in (m->complex8_decl);
+ add_simd_flag_for_built_in (m->real10_decl);
+ add_simd_flag_for_built_in (m->complex10_decl);
+ add_simd_flag_for_built_in (m->real16_decl);
+ add_simd_flag_for_built_in (m->complex16_decl);
+ add_simd_flag_for_built_in (m->real16_decl);
+ add_simd_flag_for_built_in (m->complex16_decl);
+ }
+
+ /* Release all strings. */
+ if (gfc_vectorized_builtins != NULL)
+ {
+ for (hash_map<nofree_string_hash, int>::iterator it
+ = gfc_vectorized_builtins->begin ();
+ it != gfc_vectorized_builtins->end (); ++it)
+ free (CONST_CAST (char *, (*it).first));
+
+ delete gfc_vectorized_builtins;
+ gfc_vectorized_builtins = NULL;
+ }
+}
/* Initialize function decls for library functions. The external functions
are created as required. Builtin functions are added here. */
diff --git a/gcc/gcc.c b/gcc/gcc.c
index c0d17eb4f1b..4d01e1e2f3b 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -408,6 +408,7 @@ static const char *pass_through_libs_spec_func (int, const char **);
static const char *replace_extension_spec_func (int, const char **);
static const char *greater_than_spec_func (int, const char **);
static const char *debug_level_greater_than_spec_func (int, const char **);
+static const char *find_fortran_preinclude_file (int, const char **);
static char *convert_white_space (char *);
\f
/* The Specs Language
@@ -1647,6 +1648,7 @@ static const struct spec_function static_spec_functions[] =
{ "replace-extension", replace_extension_spec_func },
{ "gt", greater_than_spec_func },
{ "debug-level-gt", debug_level_greater_than_spec_func },
+ { "fortran-preinclude-file", find_fortran_preinclude_file},
#ifdef EXTRA_SPEC_FUNCTIONS
EXTRA_SPEC_FUNCTIONS
#endif
@@ -9889,6 +9891,23 @@ debug_level_greater_than_spec_func (int argc, const char **argv)
return NULL;
}
+/* The function takes 2 arguments: OPTION name and file name.
+ When the FILE is found by find_file, return OPTION=path_to_file. */
+
+static const char *
+find_fortran_preinclude_file (int argc, const char **argv)
+{
+ if (argc != 2)
+ return NULL;
+
+ const char *path = find_a_file (&include_prefixes, argv[1], R_OK, true);
+ if (path != NULL)
+ return concat (argv[0], path, NULL);
+
+ return NULL;
+}
+
+
/* Insert backslash before spaces in ORIG (usually a file path), to
avoid being broken by spec parser.
diff --git a/gcc/testsuite/gfortran.dg/simd-builtins-1.f90 b/gcc/testsuite/gfortran.dg/simd-builtins-1.f90
new file mode 100644
index 00000000000..e5ee380943f
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/simd-builtins-1.f90
@@ -0,0 +1,19 @@
+! { dg-do compile { target { i?86-*-linux* x86_64-*-linux* } } }
+! { dg-additional-options "-msse2 -nostdinc -Ofast -fpre-include=simd-builtins-1.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
+ y4 = sin(x8)
+ print *, y8
+end
+
+! { dg-final { scan-tree-dump "sinf.simdclone" "optimized" } } */
+! { dg-final { scan-tree-dump "__builtin_sin" "optimized" } } */
+! { dg-final { scan-assembler "call.*_ZGVbN4v_sinf" } }
diff --git a/gcc/testsuite/gfortran.dg/simd-builtins-1.h b/gcc/testsuite/gfortran.dg/simd-builtins-1.h
new file mode 100644
index 00000000000..88d555cf41a
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/simd-builtins-1.h
@@ -0,0 +1,4 @@
+!GCC$ builtin (sin) attributes simd (inbranch)
+!GCC$ builtin (sinf) attributes simd (notinbranch)
+!GCC$ builtin (cosf) attributes simd
+!GCC$ builtin (cosf) attributes simd (notinbranch)
diff --git a/gcc/testsuite/gfortran.dg/simd-builtins-2.f90 b/gcc/testsuite/gfortran.dg/simd-builtins-2.f90
new file mode 100644
index 00000000000..f0e6bc13862
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/simd-builtins-2.f90
@@ -0,0 +1,20 @@
+! { dg-do compile { target { i?86-*-linux* x86_64-*-linux* } } }
+! { dg-additional-options "-msse2 -nostdinc -Ofast -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
+ y4 = sin(x8)
+ print *, y8
+end
+
+! { dg-final { scan-tree-dump "__builtin_sinf" "optimized" } } */
+! { dg-final { scan-tree-dump "__builtin_sin" "optimized" } } */
+! { dg-final { scan-tree-dump-not "simdclone" "optimized" } } */
+! { dg-final { scan-assembler-not "call.*_ZGVbN4v_sinf" } }
diff --git a/gcc/testsuite/gfortran.dg/simd-builtins-3.f90 b/gcc/testsuite/gfortran.dg/simd-builtins-3.f90
new file mode 100644
index 00000000000..949209bcf60
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/simd-builtins-3.f90
@@ -0,0 +1 @@
+! { dg-additional-options "-nostdinc -fpre-include=simd-builtins-3.h" }
diff --git a/gcc/testsuite/gfortran.dg/simd-builtins-3.h b/gcc/testsuite/gfortran.dg/simd-builtins-3.h
new file mode 100644
index 00000000000..9707ef0a628
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/simd-builtins-3.h
@@ -0,0 +1,8 @@
+!GCC$ builtin (sin) attributes simd (inbranch)
+!GCC$ builtin ( sin) attributes simd (inbranch)
+!GCC$ builtin (sin ) attributes simd (inbranch)
+!GCC$ builtin (sin) attributes simd ( inbranch)
+!GCC$ builtin (sin) attributes simd (inbranch )
+!GCC$ builtin(sin ) attributes simd ( inbranch )
+!GCC$ builtin ( sin ) attributes simd ( inbranch )
+!GCC$ builtin ( sin ) attributes simd
diff --git a/gcc/testsuite/gfortran.dg/simd-builtins-4.f b/gcc/testsuite/gfortran.dg/simd-builtins-4.f
new file mode 100644
index 00000000000..48947b6f951
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/simd-builtins-4.f
@@ -0,0 +1 @@
+! { dg-additional-options "-nostdinc -fpre-include=simd-builtins-4.h" }
diff --git a/gcc/testsuite/gfortran.dg/simd-builtins-4.h b/gcc/testsuite/gfortran.dg/simd-builtins-4.h
new file mode 100644
index 00000000000..9707ef0a628
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/simd-builtins-4.h
@@ -0,0 +1,8 @@
+!GCC$ builtin (sin) attributes simd (inbranch)
+!GCC$ builtin ( sin) attributes simd (inbranch)
+!GCC$ builtin (sin ) attributes simd (inbranch)
+!GCC$ builtin (sin) attributes simd ( inbranch)
+!GCC$ builtin (sin) attributes simd (inbranch )
+!GCC$ builtin(sin ) attributes simd ( inbranch )
+!GCC$ builtin ( sin ) attributes simd ( inbranch )
+!GCC$ builtin ( sin ) attributes simd
diff --git a/gcc/testsuite/gfortran.dg/simd-builtins-5.f b/gcc/testsuite/gfortran.dg/simd-builtins-5.f
new file mode 100644
index 00000000000..55330a8306d
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/simd-builtins-5.f
@@ -0,0 +1,9 @@
+! { dg-do compile }
+
+!GCC$ buil tin (s in) attributes simd (inbranch)
+!GCC$ builtin (sinf) at tributes simd (notinbranch)
+!GCC$ builtin (cosf) att r i bu tes s imd
+!GCC$ buil ti n ( cosf) attrib utes simd (noti nbranch)
+
+ PROGRAM Z
+ END
diff --git a/gcc/testsuite/gfortran.dg/simd-builtins-6.f90 b/gcc/testsuite/gfortran.dg/simd-builtins-6.f90
new file mode 100644
index 00000000000..5ff99212cf1
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/simd-builtins-6.f90
@@ -0,0 +1,24 @@
+! { dg-do compile { target { i?86-*-linux* x86_64-*-linux* } } }
+! { dg-additional-options "-msse2 -nostdinc -Ofast -fdump-tree-optimized" }
+
+!GCC$ builtin (sin) attributes simd (inbranch)
+!GCC$ builtin (sinf) attributes simd (notinbranch)
+!GCC$ builtin (cosf) attributes simd
+!GCC$ builtin (cosf) attributes simd (notinbranch)
+
+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
+ y4 = sin(x8)
+ print *, y8
+end
+
+! { dg-final { scan-tree-dump "sinf.simdclone" "optimized" } } */
+! { dg-final { scan-tree-dump "__builtin_sin" "optimized" } } */
+! { dg-final { scan-assembler "call.*_ZGVbN4v_sinf" } }
--
2.19.1
next prev parent reply other threads:[~2018-11-19 12:16 UTC|newest]
Thread overview: 94+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <d749cd46-e231-1405-5713-ae7d966ff8c1@suse.cz>
[not found] ` <CAFiYyc0QyhpvQxam9E3BHn2hPkr1izQM13oo+_QvkhQvwroJqw@mail.gmail.com>
[not found] ` <ee42ab7d-12b8-d7d2-1769-1c96252bbd7b@netcologne.de>
[not found] ` <CAFiYyc1cHpw-7CEE8-1ipqHKCqpL+sX6dWOCK88iVk0cn2Mm8A@mail.gmail.com>
[not found] ` <48dcb864-bad1-5e09-d209-def296ed1cd3@suse.cz>
[not found] ` <676acdda-1253-b3bd-4e03-60298c4c995c@netcologne.de>
[not found] ` <4f37f79f-647a-4851-2ff2-e0e5592b3e7f@suse.cz>
[not found] ` <2082f59c-7c61-6b81-79f7-addf70da39fa@netcologne.de>
[not found] ` <CAFiYyc2AFExBnak5YX8-L_STQYxORuwWHnD9ETRMWN3u0gB1gg@mail.gmail.com>
[not found] ` <6b852ddd-001c-40d6-383b-0b36f3d13ee7@suse.cz>
[not found] ` <CAFiYyc2Q4eXBXBSisaWDE2JH_tS82AnZBPJv1D9fkZnAQpz0CA@mail.gmail.com>
[not found] ` <60df9de6-9607-c88a-de0d-1f2c83bf3970@suse.cz>
[not found] ` <D6325C52-AE0D-49DB-86A2-F5CBDE6BAC0B@gmail.com>
[not found] ` <916e3e10-e020-f4f3-6f8e-c57909c81d55@suse.cz>
[not found] ` <CAFiYyc14yjzAojw0o+mJoLvBwobLGhN1ppLKHOt56wan_-ApZw@mail.gmail.com>
[not found] ` <20181112163347.4cc3537e@nbbrfq.loc>
[not found] ` <CAFiYyc1cczXvCf1v4PPhHVmuvT_W8RuU+8R05vjuJ=_c_nP-6w@mail.gmail.com>
2018-11-14 10:06 ` [PATCH] Support simd function declarations via a pre-include. (was: [PATCH][RFC]Overloading intrinsics) Martin Liška
2018-11-14 11:35 ` Jakub Jelinek
2018-11-14 11:56 ` Jakub Jelinek
2018-11-14 11:57 ` Jakub Jelinek
2018-11-14 14:09 ` [PATCH] Support simd function declarations via a pre-include Martin Liška
2018-11-14 14:14 ` Jakub Jelinek
2018-11-15 19:40 ` [PATCH] Support simd function declarations via a pre-include. (was: [PATCH][RFC]Overloading intrinsics) Bernhard Reutner-Fischer
2018-11-15 20:54 ` Jakub Jelinek
2018-11-16 13:25 ` [PATCH] Support simd function declarations via a pre-include Martin Liška
2018-11-16 13:50 ` Jakub Jelinek
2018-11-16 15:12 ` Martin Liška
2018-11-17 13:30 ` Paul Richard Thomas
2018-11-17 17:57 ` Paul Richard Thomas
2018-11-17 18:16 ` Bernhard Reutner-Fischer
2018-11-19 12:14 ` Martin Liška
2018-11-19 12:16 ` Martin Liška [this message]
2018-11-19 12:33 ` Jakub Jelinek
2018-11-20 14:14 ` [PATCH][RFC] Extend locations where to seach for Fortran pre-include Martin Liška
2018-11-20 14:27 ` Jakub Jelinek
2018-11-20 18:11 ` Joseph Myers
2018-11-22 8:58 ` Martin Liška
2018-11-22 14:35 ` Joseph Myers
2018-11-23 13:59 ` Martin Liška
2018-11-23 18:08 ` Joseph Myers
2018-11-26 12:20 ` Martin Liška
2018-11-26 16:19 ` Matthias Klose
2018-11-26 16:35 ` Martin Liška
2018-11-26 18:33 ` Joseph Myers
2018-11-27 13:34 ` Martin Liška
2018-11-27 7:57 ` Thomas Koenig
2018-11-27 13:32 ` Martin Liška
2018-11-27 16:22 ` Steve Ellcey
2018-11-27 21:12 ` Thomas Koenig
2019-02-18 13:23 ` Martin Liška
2019-02-19 18:18 ` Steve Kargl
2019-02-20 7:09 ` Bernhard Reutner-Fischer
2019-02-20 9:23 ` Martin Liška
2019-02-20 9:37 ` Thomas König
2019-02-20 14:17 ` Martin Liška
2019-02-20 20:11 ` Thomas König
2019-02-20 9:52 ` Bernhard Reutner-Fischer
2019-02-20 9:57 ` Martin Liška
2019-02-20 10:46 ` Bernhard Reutner-Fischer
2019-02-20 11:12 ` Martin Liška
2018-11-26 16:54 ` Martin Liška
2018-11-26 18:45 ` Joseph Myers
2018-11-27 13:40 ` Martin Liška
2018-11-30 13:51 ` Martin Liška
2019-01-09 16:01 ` Martin Liška
2019-01-09 17:16 ` Joseph Myers
2019-01-09 17:21 ` Joseph Myers
2019-01-11 15:17 ` Martin Liška
2019-01-11 18:06 ` Joseph Myers
2019-01-14 14:09 ` Martin Liška
2019-01-15 17:45 ` Joseph Myers
2019-01-16 9:42 ` Fortran vector math header Martin Liška
2019-01-16 12:39 ` Jakub Jelinek
2019-01-16 14:05 ` Joseph Myers
2019-01-16 17:42 ` Joseph Myers
2019-01-16 18:04 ` Jakub Jelinek
2019-01-16 20:35 ` Joseph Myers
2019-01-18 8:18 ` Martin Liška
2019-01-18 8:40 ` Jakub Jelinek
2019-01-21 7:47 ` Martin Liška
2019-01-21 7:58 ` Jakub Jelinek
2019-01-21 9:09 ` Martin Liška
2019-01-21 9:19 ` Jakub Jelinek
2019-01-21 9:36 ` Martin Liška
2019-01-21 9:40 ` Jakub Jelinek
2019-01-21 14:25 ` Joseph Myers
2019-01-22 11:01 ` Martin Liška
2019-01-22 11:15 ` Jakub Jelinek
2019-01-22 12:18 ` Richard Biener
2019-01-23 1:18 ` Joseph Myers
2019-01-24 14:59 ` Martin Liška
2019-01-24 15:11 ` Jakub Jelinek
2019-01-24 15:36 ` Martin Liška
2019-01-24 22:10 ` Steve Ellcey
2019-01-25 13:17 ` Martin Liška
2019-02-04 9:59 ` Martin Liška
2019-02-04 10:10 ` Jakub Jelinek
2019-02-05 1:31 ` Joseph Myers
2019-02-05 12:48 ` Martin Liška
2019-02-13 11:34 ` Martin Liška
2019-02-14 21:14 ` Steve Ellcey
2019-02-15 11:16 ` Martin Liška
2019-02-05 12:48 ` Martin Liška
2019-02-14 18:27 ` Joseph Myers
2019-02-16 0:05 ` Steve Kargl
2019-01-23 22:53 ` Steve Ellcey
2019-01-23 22:57 ` Jakub Jelinek
2019-01-23 23:14 ` [EXT] " Steve Ellcey
2019-01-16 13:59 ` Joseph Myers
2018-11-17 21:13 ` [PATCH] Support simd function declarations via a pre-include. (was: [PATCH][RFC]Overloading intrinsics) Bernhard Reutner-Fischer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f135e1be-4c90-aff5-e863-1f5bcf06fa44@suse.cz \
--to=mliska@suse.cz \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=rep.dot.nop@gmail.com \
--cc=richard.guenther@gmail.com \
--cc=tkoenig@netcologne.de \
--cc=toon@moene.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).