aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple.cc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2022-04-06 16:47:47 +0200
committerJakub Jelinek <jakub@redhat.com>2022-04-06 16:47:47 +0200
commit5df29fe79df659617793f955a1ea6c23a0617fe2 (patch)
treebfcac03d6d880fe0614717d5b940742f77ac6afa /gcc/gimple.cc
parentfd0024e48e94008915a6b18112efbbd8abc81ed8 (diff)
downloadgcc-5df29fe79df659617793f955a1ea6c23a0617fe2.zip
gcc-5df29fe79df659617793f955a1ea6c23a0617fe2.tar.gz
gcc-5df29fe79df659617793f955a1ea6c23a0617fe2.tar.bz2
gimple.cc: Follow-up to adjust gimple_call_builtin_p and gimple_call_combined_fn [PR105150]
On Wed, Apr 06, 2022 at 09:41:44AM +0100, Richard Sandiford wrote: > But it seems like the magic incantation to detect “real” built-in > function calls is getting longer and longer. Can we not abstract this > in a single place rather than have to repeat the same long sequence in > multiple places? I've already committed it, so it can be only dealt with an incremental patch. Here is a patch that adjusts instead gimple_builtin_call_types_compatible_p, after the assert: if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL) if (tree decl = builtin_decl_explicit (DECL_FUNCTION_CODE (fndecl))) fndecl = decl; but we then lose the theoretical possibility of comparing against the actual user declaration. Though I guess in the gimple-fold.cc gimple-low.cc gimple-match-head.cc calls to that function we also want this rather than what they do currently. 2022-04-06 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/105150 * gimple.cc (gimple_builtin_call_types_compatible_p): Use builtin_decl_explicit here... (gimple_call_builtin_p, gimple_call_combined_fn): ... rather than here.
Diffstat (limited to 'gcc/gimple.cc')
-rw-r--r--gcc/gimple.cc36
1 files changed, 11 insertions, 25 deletions
diff --git a/gcc/gimple.cc b/gcc/gimple.cc
index 4953bf4..9e62da4 100644
--- a/gcc/gimple.cc
+++ b/gcc/gimple.cc
@@ -2788,6 +2788,10 @@ gimple_builtin_call_types_compatible_p (const gimple *stmt, tree fndecl)
{
gcc_checking_assert (DECL_BUILT_IN_CLASS (fndecl) != NOT_BUILT_IN);
+ if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
+ if (tree decl = builtin_decl_explicit (DECL_FUNCTION_CODE (fndecl)))
+ fndecl = decl;
+
tree ret = gimple_call_lhs (stmt);
if (ret
&& !useless_type_conversion_p (TREE_TYPE (ret),
@@ -2841,12 +2845,7 @@ gimple_call_builtin_p (const gimple *stmt)
if (is_gimple_call (stmt)
&& (fndecl = gimple_call_fndecl (stmt)) != NULL_TREE
&& DECL_BUILT_IN_CLASS (fndecl) != NOT_BUILT_IN)
- {
- if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
- if (tree decl = builtin_decl_explicit (DECL_FUNCTION_CODE (fndecl)))
- fndecl = decl;
- return gimple_builtin_call_types_compatible_p (stmt, fndecl);
- }
+ return gimple_builtin_call_types_compatible_p (stmt, fndecl);
return false;
}
@@ -2859,12 +2858,7 @@ gimple_call_builtin_p (const gimple *stmt, enum built_in_class klass)
if (is_gimple_call (stmt)
&& (fndecl = gimple_call_fndecl (stmt)) != NULL_TREE
&& DECL_BUILT_IN_CLASS (fndecl) == klass)
- {
- if (klass == BUILT_IN_NORMAL)
- if (tree decl = builtin_decl_explicit (DECL_FUNCTION_CODE (fndecl)))
- fndecl = decl;
- return gimple_builtin_call_types_compatible_p (stmt, fndecl);
- }
+ return gimple_builtin_call_types_compatible_p (stmt, fndecl);
return false;
}
@@ -2877,11 +2871,7 @@ gimple_call_builtin_p (const gimple *stmt, enum built_in_function code)
if (is_gimple_call (stmt)
&& (fndecl = gimple_call_fndecl (stmt)) != NULL_TREE
&& fndecl_built_in_p (fndecl, code))
- {
- if (tree decl = builtin_decl_explicit (DECL_FUNCTION_CODE (fndecl)))
- fndecl = decl;
- return gimple_builtin_call_types_compatible_p (stmt, fndecl);
- }
+ return gimple_builtin_call_types_compatible_p (stmt, fndecl);
return false;
}
@@ -2898,14 +2888,10 @@ gimple_call_combined_fn (const gimple *stmt)
return as_combined_fn (gimple_call_internal_fn (call));
tree fndecl = gimple_call_fndecl (stmt);
- if (fndecl && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL))
- {
- tree decl = builtin_decl_explicit (DECL_FUNCTION_CODE (fndecl));
- if (!decl)
- decl = fndecl;
- if (gimple_builtin_call_types_compatible_p (stmt, decl))
- return as_combined_fn (DECL_FUNCTION_CODE (fndecl));
- }
+ if (fndecl
+ && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL)
+ && gimple_builtin_call_types_compatible_p (stmt, fndecl))
+ return as_combined_fn (DECL_FUNCTION_CODE (fndecl));
}
return CFN_LAST;
}