- if (GET_MODE (args[i].value) != VOIDmode
- && GET_MODE (args[i].value) != args[i].mode)
- args[i].value = convert_to_mode (args[i].mode, args[i].value,
- args[i].unsignedp);
+ if (args[i].mode != TYPE_MODE (TREE_TYPE (args[i].tree_value)))
+ args[i].value
+ = convert_modes (args[i].mode,
+ TYPE_MODE (TREE_TYPE (args[i].tree_value)),
+ args[i].value, args[i].unsignedp);
+
+ /* If the value is expensive, and we are inside an appropriately
+ short loop, put the value into a pseudo and then put the pseudo
+ into the hard reg.
+
+ For small register classes, also do this if this call uses
+ register parameters. This is to avoid reload conflicts while
+ loading the parameters registers. */
+
+ if ((! (GET_CODE (args[i].value) == REG
+ || (GET_CODE (args[i].value) == SUBREG
+ && GET_CODE (SUBREG_REG (args[i].value)) == REG)))
+ && args[i].mode != BLKmode
+ && rtx_cost (args[i].value, SET) > 2
+#ifdef SMALL_REGISTER_CLASSES
+ && (reg_parm_seen || preserve_subexpressions_p ()))
+#else
+ && preserve_subexpressions_p ())
+#endif
+ args[i].value = copy_to_mode_reg (args[i].mode, args[i].value);