+/* Look through the CALL_INSN_FUNCTION_USAGE of a call insn INSN, and see if
+ we find a SET rtx that we can use to deduce that a register can be cheaply
+ caller-saved. Return such a register, or NULL_RTX if none is found. */
+static rtx
+find_call_crossed_cheap_reg (rtx insn)
+{
+ rtx cheap_reg = NULL_RTX;
+ rtx exp = CALL_INSN_FUNCTION_USAGE (insn);
+
+ while (exp != NULL)
+ {
+ rtx x = XEXP (exp, 0);
+ if (GET_CODE (x) == SET)
+ {
+ exp = x;
+ break;
+ }
+ exp = XEXP (exp, 1);
+ }
+ if (exp != NULL)
+ {
+ basic_block bb = BLOCK_FOR_INSN (insn);
+ rtx reg = SET_SRC (exp);
+ rtx prev = PREV_INSN (insn);
+ while (prev && !(INSN_P (prev)
+ && BLOCK_FOR_INSN (prev) != bb))
+ {
+ if (NONDEBUG_INSN_P (prev))
+ {
+ rtx set = single_set (prev);
+
+ if (set && rtx_equal_p (SET_DEST (set), reg))
+ {
+ rtx src = SET_SRC (set);
+ if (!REG_P (src) || HARD_REGISTER_P (src)
+ || !pseudo_regno_single_word_and_live_p (REGNO (src)))
+ break;
+ if (!modified_between_p (src, prev, insn))
+ cheap_reg = src;
+ break;
+ }
+ if (set && rtx_equal_p (SET_SRC (set), reg))
+ {
+ rtx dest = SET_DEST (set);
+ if (!REG_P (dest) || HARD_REGISTER_P (dest)
+ || !pseudo_regno_single_word_and_live_p (REGNO (dest)))
+ break;
+ if (!modified_between_p (dest, prev, insn))
+ cheap_reg = dest;
+ break;
+ }
+
+ if (reg_overlap_mentioned_p (reg, PATTERN (prev)))
+ break;
+ }
+ prev = PREV_INSN (prev);
+ }
+ }
+ return cheap_reg;
+}
+