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 <luo...@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