https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117801

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #6)
> It's a property that would perfectly match a register "pressure" (it's not
> really about pressure but register coalescing sensitive) sched1.
> 
> For the specific case I wonder why TER doesn't come to rescue here?  I
> suppose we never TER internal function calls even when direct-optab?
> (not that I really want to suggest to expand what TER does, but this might
> be an acceptable knob to get back the performance for GCC 15)

Indeed.

bool
ssa_is_replaceable_p (gimple *stmt)
{
  use_operand_p use_p;
  tree def;
  gimple *use_stmt;

  /* Only consider modify stmts.  */
  if (!is_gimple_assign (stmt))
    return false;

...

  /* No function calls can be replaced.  */
  if (is_gimple_call (stmt))
    return false;

for consistency (we're doing more and more direct-optab IFNs replacing
gimple assign sequences) we want to handle those as replaceable.

The following might work:

diff --git a/gcc/tree-outof-ssa.cc b/gcc/tree-outof-ssa.cc
index 3df8054a729..e01523cb4cc 100644
--- a/gcc/tree-outof-ssa.cc
+++ b/gcc/tree-outof-ssa.cc
@@ -45,6 +45,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-ssa-coalesce.h"
 #include "tree-outof-ssa.h"
 #include "dojump.h"
+#include "internal-fn.h"

 /* FIXME: A lot of code here deals with expanding to RTL.  All that code
    should be in cfgexpand.cc.  */
@@ -60,8 +61,11 @@ ssa_is_replaceable_p (gimple *stmt)
   tree def;
   gimple *use_stmt;

-  /* Only consider modify stmts.  */
-  if (!is_gimple_assign (stmt))
+  /* Only consider modify stmts and direct internal fn calls.  */
+  if (!is_gimple_assign (stmt)
+      && (!is_gimple_call (stmt)
+         || !gimple_call_internal_p (stmt)
+         || !direct_internal_fn_p (gimple_call_internal_fn (stmt))))
     return false;

   /* If the statement may throw an exception, it cannot be replaced.  */
@@ -96,10 +100,6 @@ ssa_is_replaceable_p (gimple *stmt)
       && DECL_HARD_REGISTER (gimple_assign_rhs1 (stmt)))
     return false;

-  /* No function calls can be replaced.  */
-  if (is_gimple_call (stmt))
-    return false;
-
   /* Leave any stmt with volatile operands alone as well.  */
   if (gimple_has_volatile_ops (stmt))
     return false;

but it surely needs adjustments for the TER helpers to expect calls
(a quick check shows get_def_for_expr assumes an assignment, the
easiest way might be to make get_gimple_for_ssa_name return NULL
for non-assigns.

Reply via email to