@@ -1904,6 +1904,12 @@ can_combine_p (rtx_insn *insn, rtx_insn *i3, rtx_insn
*pred ATTRIBUTE_UNUSED,
set = expand_field_assignment (set);
src = SET_SRC (set), dest = SET_DEST (set);
+ /* Don't combine if dest contains a user specified register, because the
+ user specified register (same with dest) in i3 would be replaced by
the
+ src of insn which might be different with the user's expectation. */
+ if (REG_P (dest) && REG_USERVAR_P (dest) && HARD_REGISTER_P (dest))
+ return 0;
+
/* Don't eliminate a store in the stack pointer. */
if (dest == stack_pointer_rtx
/* Don't combine with an insn that sets a register to itself if it
has
b/gcc/testsuite/gcc.target/arm/pr64818.c
new file mode 100644
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-options "-O1" } */
+
+char temp[16];
+extern int foo1 (void);
+
+void foo (void)
+{
+ int i;
+ int len;
+
+ while (1)
+ {
+ len = foo1 ();
+ register int a asm ("r0") = 5;
+ register char *b asm ("r1") = temp;
+ register int c asm ("r2") = len;
+ asm volatile ("mov %[r0], %[r0]\n mov %[r1], %[r1]\n mov %[r2],
%[r2]\n"
+ : "+m"(*b)
+ : [r0]"r"(a), [r1]"r"(b), [r2]"r"(c));
+
+ for (i = 0; i < len; i++)
+ {
+ if (temp[i] == 10)
+ return;
+ }
+ }
+}
+