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

Kishan Parmar <kishan at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2026-12-02

--- Comment #1 from Kishan Parmar <kishan at gcc dot gnu.org> ---
Below patch should resolve this issue.

diff --git a/gcc/config/rs6000/rs6000-builtin.cc
b/gcc/config/rs6000/rs6000-builtin.cc
index df9ec7a4a08..9e7fb9250a4 100644
--- a/gcc/config/rs6000/rs6000-builtin.cc
+++ b/gcc/config/rs6000/rs6000-builtin.cc
@@ -3113,14 +3113,25 @@ mma_expand_builtin (tree exp, rtx target, insn_code
icode,
        }

       /* Some MMA instructions have INOUT accumulator operands, so force
-        their target register to be the same as their input register.  */
+        their target register to be the same as their input register.  The
+        input may still be live after this builtin, and TARGET may also be
+        the register of a later operand, so do not write to either of them
+        here.  Copy the input into a new register and update that instead.  */
       if (!void_func
          && nopnds == 1
          && !strcmp (insn_op->constraint, "0")
          && insn_op->mode == tmode
          && REG_P (opnd)
          && insn_data[icode].operand[0].predicate (opnd, tmode))
-       target = op[0] = opnd;
+       {
+         if (!rtx_equal_p (target, opnd))
+           {
+             rtx tied = gen_reg_rtx (tmode);
+             emit_move_insn (tied, opnd);
+             target = op[0] = tied;
+           }
+         opnd = target;
+       }

       op[nopnds++] = opnd;
     }

Reply via email to