public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-8022] gimple.cc: Follow-up to adjust gimple_call_builtin_p and gimple_call_combined_fn [PR105150]
Date: Wed,  6 Apr 2022 14:49:39 +0000 (GMT)	[thread overview]
Message-ID: <20220406144939.DA9B13857815@sourceware.org> (raw)

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;
 }


                 reply	other threads:[~2022-04-06 14:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220406144939.DA9B13857815@sourceware.org \
    --to=jakub@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).