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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org

--- Comment #19 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
--- gcc/tree-inline.cc.jj       2026-02-17 15:56:32.000000000 +0100
+++ gcc/tree-inline.cc  2026-03-05 18:39:59.590916480 +0100
@@ -5336,7 +5336,20 @@ expand_call_inline (basic_block bb, gimp
   if (use_retvar && gimple_call_lhs (stmt))
     {
       gimple *old_stmt = stmt;
-      stmt = gimple_build_assign (gimple_call_lhs (stmt), use_retvar);
+      tree lhs = gimple_call_lhs (stmt);
+      if (!is_gimple_reg (lhs)
+         && !is_gimple_reg (use_retvar)
+         && is_gimple_reg_type (TREE_TYPE (lhs)))
+       {
+         /* If both lhs and use_retvar aren't gimple regs, yet have
+            gimple reg type, copy through a temporary SSA_NAME.  */
+         gimple *g = gimple_build_assign (make_ssa_name (TREE_TYPE (lhs)),
+                                          use_retvar);
+         gimple_set_location (g, gimple_location (old_stmt));
+         gsi_insert_before (&stmt_gsi, g, GSI_SAME_STMT);
+         use_retvar = gimple_assign_lhs (g);
+       }
+      stmt = gimple_build_assign (lhs, use_retvar);
       gimple_set_location (stmt, gimple_location (old_stmt));
       gsi_replace (&stmt_gsi, stmt, false);
       maybe_clean_or_replace_eh_stmt (old_stmt, stmt);

fixes this.

Reply via email to