This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Add MD Function type check for builtin_md vectorize
- From: Xiong Hu Luo <luoxhu at linux dot ibm dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: richard dot sandiford at arm dot com, rguenth at gcc dot gnu dot org, segher at kernel dot crashing dot org, wschmidt at linux dot ibm dot com, luoxhu at linux dot ibm dot com
- Date: Tue, 20 Aug 2019 22:25:36 -0400
- Subject: [PATCH] Add MD Function type check for builtin_md vectorize
The DECL_MD_FUNCTION_CODE added in r274404(PR 91421) by rsandifo requires that
DECL to be a BUILTIN_IN_MD class built-in, asserts will happen when lto
as the patch r274411(PR 91287) outputs some math function symbol to the object,
this patch will check function type before do builtin_md vectorize.
gcc/ChangeLog
2019-08-21 Xiong Hu Luo <luoxhu@linux.ibm.com>
* tree-vect-stmts.c (vectorizable_call): Check callee built-in type.
* gcc/tree.h (DECL_MD_FUNCTION_P): New function.
---
gcc/tree-vect-stmts.c | 2 +-
gcc/tree.h | 12 ++++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 1e2dfe5d22d..ef947f20d63 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -3376,7 +3376,7 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
if (cfn != CFN_LAST)
fndecl = targetm.vectorize.builtin_vectorized_function
(cfn, vectype_out, vectype_in);
- else if (callee)
+ else if (callee && DECL_MD_FUNCTION_P (callee))
fndecl = targetm.vectorize.builtin_md_vectorized_function
(callee, vectype_out, vectype_in);
}
diff --git a/gcc/tree.h b/gcc/tree.h
index b910c5cb475..8cce89e5cf3 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -3905,6 +3905,18 @@ DECL_MD_FUNCTION_CODE (const_tree decl)
return fndecl.function_code;
}
+/* Return true if decl is a FUNCTION_DECL with built-in class BUILT_IN_MD.
+ Otherwise return false. */
+inline bool
+DECL_MD_FUNCTION_P (const_tree decl)
+{
+ const tree_function_decl &fndecl = FUNCTION_DECL_CHECK (decl)->function_decl;
+ if (fndecl.built_in_class == BUILT_IN_MD)
+ return true;
+ else
+ return false;
+}
+
/* Return the frontend-specific built-in function that DECL represents,
given that it is known to be a FUNCTION_DECL with built-in class
BUILT_IN_FRONTEND. */
--
2.22.0.428.g6d5b264208