Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 190151)
+++ config/i386/i386.c	(working copy)
@@ -17313,9 +17313,16 @@
       rtx shift_count = XEXP (shift_rtx, 1);
 
       /* Return true if shift count is dest of SET_BODY.  */
-      if (REG_P (shift_count)
-	  && true_regnum (set_dest) == true_regnum (shift_count))
-	return true;
+      if (REG_P (shift_count))
+        {
+          /* Add check since it can be invoked before register
+             allocation in schedule1. */
+          if (reload_completed
+	      && true_regnum (set_dest) == true_regnum (shift_count))
+	    return true;
+          else if (REGNO(set_dest) == REGNO(shift_count))
+            return true;
+        }  
     }
 
   return false;
@@ -24183,6 +24190,113 @@
   return issue_rate;
 }
 
+/* Return true if insn is copy of hardware function argument register. */
+static bool
+move_from_func_arg_reg (rtx insn)
+{
+  rtx src;
+  if (!NONDEBUG_INSN_P (insn))
+    return false;
+  insn = PATTERN (insn);
+  if (GET_CODE (insn) == PARALLEL)
+    insn = XVECEXP (insn, 0, 0);
+  if (GET_CODE (insn) != SET)
+    return false;
+  src = SET_SRC (insn);
+  if (REG_P (src) && HARD_REGISTER_P (src)
+      && ix86_function_arg_regno_p (REGNO (src)))
+    return true;
+  return false;
+}
+
+/* Returns true if lhs of rtl is hardware function argument register. */
+static bool
+insn_is_function_arg (rtx insn)
+{
+  rtx dst;
+
+  if (!NONDEBUG_INSN_P (insn))
+    return false;
+  insn = PATTERN (insn);
+  if (GET_CODE (insn) == PARALLEL)
+    insn = XVECEXP (insn, 0, 0);
+  if (GET_CODE (insn) != SET)
+    return false;
+  dst = SET_DEST (insn);
+  if (REG_P (dst) && HARD_REGISTER_P (dst)
+      && ix86_function_arg_regno_p (REGNO (dst)))
+    return true;
+  return false;
+}
+
+/* Add output dependencies for chain of function arguments. */
+static void
+add_parameter_dependencies (rtx call, rtx head)
+{
+  rtx insn, last = call;
+
+  /* Find nearest to call argument passing instruction. */
+  while (true)
+    {
+      last = PREV_INSN (last);
+      if (last == head)
+        return;
+      if (!NONDEBUG_INSN_P (last))
+        continue;
+      if (insn_is_function_arg (last))
+        break;
+      return; 
+    }
+    
+  while (true)
+    {
+      insn = PREV_INSN (last);
+      if (!INSN_P (insn))
+        break;
+      if (insn == head)
+        break;
+      if (!NONDEBUG_INSN_P (insn))
+        continue;
+      if (insn_is_function_arg (insn))
+        {
+           /* Add output depdendence between two function arguments. */
+           add_dependence (last, insn, REG_DEP_OUTPUT);
+           last = insn;
+        }
+      else
+        break;
+    }
+}
+
+/* Hook for schedule1 - add ouput dependencies for all function arguments
+   to preserve the scheduling order of arguments. */
+static void
+ix86_dependencies_evaluation_hook (rtx head, rtx tail)
+{
+  rtx insn;
+  if (reload_completed)
+    return;
+  for (insn = tail; insn != head; insn = PREV_INSN (insn))
+    if (INSN_P (insn) && CALL_P (insn))
+      add_parameter_dependencies (insn, head);
+}
+
+/* Hook for schedule1 - mark all copy of incoming function arguments with
+   max priority to schedule them as soon as possible. */ 
+static int
+ix86_adjust_priority (rtx insn, int priority)
+{
+  if (reload_completed)
+    return priority;
+
+  if (move_from_func_arg_reg (insn))
+    {
+      /* set max priority for it. */
+      return current_sched_info->sched_max_insns_priority;
+    }
+  return priority;
+}  
+
 
 
 /* Model decoder of Core 2/i7.
@@ -39406,6 +39520,10 @@
 #define TARGET_SCHED_REASSOCIATION_WIDTH ix86_reassociation_width
 #undef TARGET_SCHED_REORDER
 #define TARGET_SCHED_REORDER ix86_sched_reorder
+#undef TARGET_SCHED_ADJUST_PRIORITY
+#define TARGET_SCHED_ADJUST_PRIORITY ix86_adjust_priority
+#undef TARGET_SCHED_DEPENDENCIES_EVALUATION_HOOK
+#define TARGET_SCHED_DEPENDENCIES_EVALUATION_HOOK ix86_dependencies_evaluation_hook
 
 /* The size of the dispatch window is the total number of bytes of
    object code allowed in a window.  */
