Add MD Function type check for builtin_md vectorize
diff mbox series

Message ID 20190821022536.64555-1-luoxhu@linux.ibm.com
State New
Headers show
Series
  • Add MD Function type check for builtin_md vectorize
Related show

Commit Message

luoxhu Aug. 21, 2019, 2:25 a.m. UTC
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(-)

Comments

Richard Biener Aug. 21, 2019, 7:40 a.m. UTC | #1
On Tue, 20 Aug 2019, Xiong Hu Luo wrote:

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

I think Richard fixed this already.

Richard.

> 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.  */
>
luoxhu Aug. 22, 2019, 2:44 a.m. UTC | #2
On 2019/8/21 15:40, Richard Biener wrote:
> On Tue, 20 Aug 2019, Xiong Hu Luo wrote:
> 
>> 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.
> 
> I think Richard fixed this already.

Thanks. It was fixed by Richard's r274524 already. Please ignore this
patch.

Xionghu

> 
> Richard.
> 
>> 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.  */
>>
>

Patch
diff mbox series

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.  */