Index: osprey/be/cg/localize.cxx
===================================================================
--- osprey/be/cg/localize.cxx   (revision 3734)
+++ osprey/be/cg/localize.cxx   (working copy)
@@ -534,8 +534,11 @@
        {
                if (def && BB_call(current_bb))
                        ;       // okay
-               else if (def && BB_asm(current_bb))
+               else if (BB_asm(current_bb))
                        ;       // okay
+               else if (BB_prev(current_bb) != NULL
+                        && BB_asm(BB_prev(current_bb)))
+                        ;       // okay
                else if (def && !BB_call(current_bb)) {
                        Localize_Global_Param_Reg (current_bb, tn);
                }
Index: osprey/be/cg/ia64/cgtarget.cxx
===================================================================
--- osprey/be/cg/ia64/cgtarget.cxx      (revision 3734)
+++ osprey/be/cg/ia64/cgtarget.cxx      (working copy)
@@ -3650,6 +3650,13 @@
     ret_tn = (pref_tn ? pref_tn : Build_TN_Of_Mtype(rtype));
   }

+  else if (*constraint == 'b') {
+    TYPE_ID rtype = (load != NULL ? WN_rtype(load) : Pointer_Mtype);
+    FmtAssert(rtype == Pointer_Mtype,
+              ("ASM operand does not satisfy its constraint"));
+    ret_tn = (pref_tn ? pref_tn : Build_TN_Of_Mtype(MTYPE_A8));
+  }
+
   else {
     FmtAssert(FALSE, ("ASM constraint <%s> not supported", constraint));
   }
Index: osprey/be/cg/ia64/exp_loadstore.cxx
===================================================================
--- osprey/be/cg/ia64/exp_loadstore.cxx (revision 3734)
+++ osprey/be/cg/ia64/exp_loadstore.cxx (working copy)
@@ -169,9 +169,14 @@
     Build_OP (top, result, True_TN, Gen_Enum_TN(ldhint), base, ops);
   } else {
     ISA_ENUM_CLASS_VALUE ldtype = Pick_Load_Type (variant, mtype);
-    Build_OP (top, result, True_TN,
+    // can not load to branch register directly
+    TN* tmp_res = (TN_register_class(result) == ISA_REGISTER_CLASS_branch) ?
+                  Build_TN_Of_Mtype(mtype) : result;
+    Build_OP (top, tmp_res, True_TN,
              Gen_Enum_TN(ldtype), Gen_Enum_TN(ldhint),
              base, ops);
+    if (tmp_res != result)
+      Exp_COPY(result, tmp_res, ops);
   }
 }

@@ -260,8 +265,14 @@
     Build_OP (top, True_TN, Gen_Enum_TN(sthint), base, src, ops);
   } else {
     ISA_ENUM_CLASS_VALUE sttype = Pick_Store_Type (variant);
+    // can not store branch register to memory directly
+    TN* tmp_src = src;
+    if (TN_register_class(src) == ISA_REGISTER_CLASS_branch) {
+      tmp_src = Build_TN_Of_Mtype(mtype);
+      Exp_COPY(tmp_src, src, ops);
+    }
     Build_OP (top, True_TN, Gen_Enum_TN(sttype), Gen_Enum_TN(sthint),
-             base, src, ops);
+             base, tmp_src, ops);
   }
 }

@@ -491,8 +502,14 @@
     }
     Reset_TN_is_fpu_int(result);
   }
-  else
-    Expand_Composed_Load(op, result, base, disp, variant, ops);
+  else {
+    // can not load to branch register directly
+    TN* tmp_res = (TN_register_class(result) == ISA_REGISTER_CLASS_branch) ?
+                  Build_TN_Of_Mtype(rtype) : result;
+    Expand_Composed_Load(op, tmp_res, base, disp, variant, ops);
+    if (tmp_res != result)
+      Exp_COPY(result, tmp_res, ops);
+  }
 }


@@ -608,8 +625,15 @@
       /*NOTREACHED*/
     }
   }
-  else
-    Expand_Composed_Store(mtype, obj, base, disp, variant, ops);
+  else {
+    // can not store branch register to memory directly
+    TN* tmp_obj = obj;
+    if (TN_register_class(obj) == ISA_REGISTER_CLASS_branch) {
+      tmp_obj = Build_TN_Of_Mtype(mtype);
+      Exp_COPY(tmp_obj, obj, ops);
+    }
+    Expand_Composed_Store(mtype, tmp_obj, base, disp, variant, ops);
+  }
 }

 static void
Index: osprey/be/cg/whirl2ops.cxx
===================================================================
--- osprey/be/cg/whirl2ops.cxx  (revision 3734)
+++ osprey/be/cg/whirl2ops.cxx  (working copy)
@@ -1421,6 +1421,10 @@
   else {
     i += Int_Preg_Min_Offset;
   }
+#elif defined(TARG_IA64)
+  else if (TN_register_class(tn) == ISA_REGISTER_CLASS_branch) {
+    i += Branch_Preg_Min_Offset;
+  }
 #endif
   return i;
 }