public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-8022] gimple.cc: Follow-up to adjust gimple_call_builtin_p and gimple_call_combined_fn [PR105150]
@ 2022-04-06 14:49 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2022-04-06 14:49 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:5df29fe79df659617793f955a1ea6c23a0617fe2
commit r12-8022-g5df29fe79df659617793f955a1ea6c23a0617fe2
Author: Jakub Jelinek <jakub@redhat.com>
Date: Wed Apr 6 16:47:47 2022 +0200
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.
Diff:
---
gcc/gimple.cc | 36 +++++++++++-------------------------
1 file changed, 11 insertions(+), 25 deletions(-)
diff --git a/gcc/gimple.cc b/gcc/gimple.cc
index 4953bf48379..9e62da4265b 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;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-04-06 14:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-06 14:49 [gcc r12-8022] gimple.cc: Follow-up to adjust gimple_call_builtin_p and gimple_call_combined_fn [PR105150] Jakub Jelinek
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).