Hi, The attached patch fixes PR 67061. Tested on sh-elf trunk r227682 with make -k check RUNTESTFLAGS="--target_board=sh-sim \{-m2/-ml,-m2/-mb,-m2a/-mb,-m4/-ml,-m4/-mb,-m4a/-ml,-m4a/-mb}"
Committed to trunk as r227750. Will backport to GCC 5 branch later. Cheers, Oleg gcc/ChangeLog: PR target/67061 * config/sh/sh-protos.h (sh_find_set_of_reg): Simplfiy for-loop. Handle call insns.
Index: gcc/config/sh/sh-protos.h =================================================================== --- gcc/config/sh/sh-protos.h (revision 227749) +++ gcc/config/sh/sh-protos.h (working copy) @@ -192,19 +192,20 @@ if (!REG_P (reg) || insn == NULL_RTX) return result; - rtx_insn* previnsn = insn; - - for (result.insn = stepfunc (insn); result.insn != NULL_RTX; - previnsn = result.insn, result.insn = stepfunc (result.insn)) + for (rtx_insn* i = stepfunc (insn); i != NULL_RTX; i = stepfunc (i)) { - if (BARRIER_P (result.insn)) + if (BARRIER_P (i)) break; - if (!NONJUMP_INSN_P (result.insn)) - continue; - if (reg_set_p (reg, result.insn)) + if (!INSN_P (i) || DEBUG_INSN_P (i)) + continue; + if (reg_set_p (reg, i)) { - result.set_rtx = set_of (reg, result.insn); + if (CALL_P (i)) + break; + result.insn = i; + result.set_rtx = set_of (reg, i); + if (result.set_rtx == NULL_RTX || GET_CODE (result.set_rtx) != SET) break; @@ -226,12 +227,6 @@ } } - /* If the loop above stopped at the first insn in the list, - result.insn will be null. Use the insn from the previous iteration - in this case. */ - if (result.insn == NULL) - result.insn = previnsn; - if (result.set_src != NULL) gcc_assert (result.insn != NULL && result.set_rtx != NULL);