diff --git a/gas/ChangeLog b/gas/ChangeLog
index 5cc7c42744c96156a90b399b9931c6e047220222..5fe349fecea4bcfd6a3650c6616a8e1772b0659c 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,10 @@
+2005-01-25  Jan Beulich  <jbeulich@novell.com>
+
+	* config/tc-ia64.c (emit_one_bundle): Add late resolution of move
+	to/from application registers dynamic insns.
+	(md_assemble): Defer resolution of move to/from application registers
+	dynamic insns when they can be issued on either the I- or M-units.
+
 2005-01-25  Alexandre Oliva  <aoliva@redhat.com>
 
 	* config/tc-frv.c (md_apply_fix3): Mark TLS symbols as such.
diff --git a/gas/config/tc-ia64.c b/gas/config/tc-ia64.c
index 75a84344bd0b328d4063c7e004ceb58ef82f47c9..d065449638a957061a8e96580dd27f40b3b15ec2 100644
--- a/gas/config/tc-ia64.c
+++ b/gas/config/tc-ia64.c
@@ -6370,25 +6370,42 @@ emit_one_bundle ()
       /* resolve dynamic opcodes such as "break", "hint", and "nop":  */
       if (idesc->type == IA64_TYPE_DYN)
 	{
+	  enum ia64_opnd opnd1, opnd2;
+
 	  if ((strcmp (idesc->name, "nop") == 0)
 	      || (strcmp (idesc->name, "hint") == 0)
 	      || (strcmp (idesc->name, "break") == 0))
 	    insn_unit = required_unit;
-	  else if (strcmp (idesc->name, "chk.s") == 0)
+	  else if (strcmp (idesc->name, "chk.s") == 0
+	      || strcmp (idesc->name, "mov") == 0)
 	    {
 	      insn_unit = IA64_UNIT_M;
-	      if (required_unit == IA64_UNIT_I)
+	      if (required_unit == IA64_UNIT_I
+		  || (required_unit == IA64_UNIT_F && template == 6))
 		insn_unit = IA64_UNIT_I;
 	    }
 	  else
 	    as_fatal ("emit_one_bundle: unexpected dynamic op");
 
 	  sprintf (mnemonic, "%s.%c", idesc->name, "?imbf??"[insn_unit]);
+	  opnd1 = idesc->operands[0];
+	  opnd2 = idesc->operands[1];
 	  ia64_free_opcode (idesc);
-	  md.slot[curr].idesc = idesc = ia64_find_opcode (mnemonic);
+	  idesc = ia64_find_opcode (mnemonic);
+	  /* moves to/from ARs have collisions */
+	  if (opnd1 == IA64_OPND_AR3 || opnd2 == IA64_OPND_AR3)
+	    {
+	      while (idesc != NULL
+		     && (idesc->operands[0] != opnd1
+			 || idesc->operands[1] != opnd2))
+		idesc = get_next_opcode (idesc);
+	    }
 #if 0
-	  know (!idesc->next);	/* no resolved dynamic ops have collisions */
+	  else
+	    /* no other resolved dynamic ops have collisions */
+	    know (!get_next_opcode (idesc));
 #endif
+	  md.slot[curr].idesc = idesc;
 	}
       else
 	{
@@ -10071,17 +10088,22 @@ md_assemble (str)
 	    {
 	      if (ar_is_only_in_integer_unit (CURR_SLOT.opnd[rop].X_add_number))
 		mnemonic = "mov.i";
-	      else
+	      else if (ar_is_only_in_memory_unit (CURR_SLOT.opnd[rop].X_add_number))
 		mnemonic = "mov.m";
+	      else
+		rop = -1;
 	    }
 	  else
 	    abort ();
-	  ia64_free_opcode (idesc);
-	  idesc = ia64_find_opcode (mnemonic);
-	  while (idesc != NULL
-		 && (idesc->operands[0] != opnd1
-		     || idesc->operands[1] != opnd2))
-	    idesc = get_next_opcode (idesc);
+	  if (rop >= 0)
+	    {
+	      ia64_free_opcode (idesc);
+	      idesc = ia64_find_opcode (mnemonic);
+	      while (idesc != NULL
+		     && (idesc->operands[0] != opnd1
+			 || idesc->operands[1] != opnd2))
+		idesc = get_next_opcode (idesc);
+	    }
 	}
     }
   else if (strcmp (idesc->name, "mov.i") == 0
diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog
index eaf1df9e518d636d901a8a060320aa2f20aff8fa..71a656706e012e7436e3436144342d5fad2ea3d0 100644
--- a/gas/testsuite/ChangeLog
+++ b/gas/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2005-01-25  Jan Beulich  <jbeulich@novell.com>
+
+	* gas/ia64/dv-waw-err.l: Don't expect ar112 move warning to refer to
+	M-unit.
+	* gas/ia64/mov-ar.[ds]: New.
+	* gas/ia64/ia64.exp: Run new test.
+
 2005-01-24  Nick Clifton  <nickc@redhat.com>
 
 	* gas/all/sleb128.d: Do not assume an 8-bit byte.
diff --git a/gas/testsuite/gas/ia64/dv-waw-err.l b/gas/testsuite/gas/ia64/dv-waw-err.l
index 6c9225b497e7b98d39a5640251decf87cf046c71..c641cb383820e6bb4c02c1237648f174d1b1c07c 100644
--- a/gas/testsuite/gas/ia64/dv-waw-err.l
+++ b/gas/testsuite/gas/ia64/dv-waw-err.l
@@ -81,7 +81,7 @@
 .*:108: Warning: This is the location of the conflicting usage
 .*:114: Warning: Use of 'st8\.spill' .* WAW dependency 'AR\[UNAT\]{%}, % in 0 - 63' \(impliedf\)
 .*:113: Warning: This is the location of the conflicting usage
-.*:119: Warning: Use of 'mov\.m' .* WAW dependency 'AR%, % in 48 - 63, 112-127' \(impliedf\), specific resource number is 48
+.*:119: Warning: Use of 'mov(\.[im])?' .* WAW dependency 'AR%, % in 48 - 63, 112-127' \(impliedf\), specific resource number is 48
 .*:118: Warning: This is the location of the conflicting usage
 .*:124: Warning: Use of 'mov' .* WAW dependency 'BR%, % in 0 - 7' \(impliedf\), specific resource number is 1
 .*:123: Warning: This is the location of the conflicting usage
diff --git a/gas/testsuite/gas/ia64/ia64.exp b/gas/testsuite/gas/ia64/ia64.exp
index 48c4b500ab86ba11dcf1e37718c60bf1d5d66398..89d3965e7679fd7646dde07e08d72a35a6fbf5ff 100644
--- a/gas/testsuite/gas/ia64/ia64.exp
+++ b/gas/testsuite/gas/ia64/ia64.exp
@@ -24,6 +24,7 @@ if [istarget "ia64-*"] then {
     run_dump_test "opc-i"
     run_dump_test "opc-m"
     run_dump_test "opc-x"
+    run_dump_test "mov-ar"
 
     run_list_test "dv-raw-err" ""
     run_list_test "dv-waw-err" ""
diff --git a/gas/testsuite/gas/ia64/mov-ar.d b/gas/testsuite/gas/ia64/mov-ar.d
new file mode 100644
index 0000000000000000000000000000000000000000..ec7cb61548bb72ff0059b1a1304c93b551491eb8
--- /dev/null
+++ b/gas/testsuite/gas/ia64/mov-ar.d
@@ -0,0 +1,26 @@
+# objdump: -d
+# name: ia64 app reg moves
+
+.*: +file format .*
+
+Disassembly of section \.text:
+
+0+0 <_start>:
+[[:space:]]*[[:xdigit:]]*:[[:space:][:xdigit:]]+\[MFI\][[:space:]]+mov\.m ar.k0=r0
+[[:space:]]*[[:xdigit:]]*:[[:space:][:xdigit:]]+nop\.f 0x0
+[[:space:]]*[[:xdigit:]]*:[[:space:][:xdigit:]]+mov\.i ar127=r0;;
+[[:space:]]*[[:xdigit:]]*:[[:space:][:xdigit:]]+\[MFI\][[:space:]]+mov\.m ar47=r0
+[[:space:]]*[[:xdigit:]]*:[[:space:][:xdigit:]]+nop\.f 0x0
+[[:space:]]*[[:xdigit:]]*:[[:space:][:xdigit:]]+mov\.i ar112=r0;;
+[[:space:]]*[[:xdigit:]]*:[[:space:][:xdigit:]]+\[MFI\][[:space:]]+mov\.m ar48=r0
+[[:space:]]*[[:xdigit:]]*:[[:space:][:xdigit:]]+nop\.f 0x0
+[[:space:]]*[[:xdigit:]]*:[[:space:][:xdigit:]]+mov\.i ar111=r0;;
+[[:space:]]*[[:xdigit:]]*:[[:space:][:xdigit:]]+\[MFI\][[:space:]]+mov\.m ar63=r0
+[[:space:]]*[[:xdigit:]]*:[[:space:][:xdigit:]]+nop\.f 0x0
+[[:space:]]*[[:xdigit:]]*:[[:space:][:xdigit:]]+mov\.i ar.pfs=r0;;
+[[:space:]]*[[:xdigit:]]*:[[:space:][:xdigit:]]+\[MFI\][[:space:]]+mov\.m ar112=r0
+[[:space:]]*[[:xdigit:]]*:[[:space:][:xdigit:]]+nop\.f 0x0
+[[:space:]]*[[:xdigit:]]*:[[:space:][:xdigit:]]+mov\.i ar63=r0;;
+[[:space:]]*[[:xdigit:]]*:[[:space:][:xdigit:]]+\[MFI\][[:space:]]+mov\.m ar127=r0
+[[:space:]]*[[:xdigit:]]*:[[:space:][:xdigit:]]+nop\.f 0x0
+[[:space:]]*[[:xdigit:]]*:[[:space:][:xdigit:]]+mov\.i ar48=r0;;
diff --git a/gas/testsuite/gas/ia64/mov-ar.s b/gas/testsuite/gas/ia64/mov-ar.s
new file mode 100644
index 0000000000000000000000000000000000000000..79780d940bcfd428dcc9af79dbd811ed67114930
--- /dev/null
+++ b/gas/testsuite/gas/ia64/mov-ar.s
@@ -0,0 +1,21 @@
+.explicit
+_start:
+{.mfi
+	mov	ar0 = r0
+	mov	ar127 = r0
+} ;; {.mfi
+	mov	ar47 = r0
+	mov	ar112 = r0
+} ;; {.mfi
+	mov	ar48 = r0
+	mov	ar111 = r0
+} ;; {.mfi
+	mov	ar63 = r0
+	mov	ar64 = r0
+} ;; {.mfi
+	mov	ar112 = r0
+	mov	ar63 = r0
+} ;; {.mfi
+	mov	ar127 = r0
+	mov	ar48 = r0
+} ;;