gimple.cc: Follow-up to adjust gimple_call_builtin_p and gimple_call_combined_fn...
authorJakub Jelinek <jakub@redhat.com>
Wed, 6 Apr 2022 14:47:47 +0000 (16:47 +0200)
committerJakub Jelinek <jakub@redhat.com>
Wed, 6 Apr 2022 14:47:47 +0000 (16:47 +0200)
commit5df29fe79df659617793f955a1ea6c23a0617fe2
treebfcac03d6d880fe0614717d5b940742f77ac6afa
parentfd0024e48e94008915a6b18112efbbd8abc81ed8
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.
gcc/gimple.cc