[backport from gcc-4.7.0 r183512, adjusted for 4.6 using rtx not 'struct insn_link *' for LOG_LINKS ] gcc/ 2012-01-25 Ramana Radhakrishnan PR rtl-optimization/48308 (do_SUBST_LINK): New. (SUBST_LINK): New. (try_combine): Handle LOG_LINKS for the dummy i1 case. --- gcc-4.6.3/gcc/combine.c.~1~ 2012-02-09 18:29:38.000000000 +0100 +++ gcc-4.6.3/gcc/combine.c 2012-06-12 18:00:22.000000000 +0200 @@ -762,6 +762,33 @@ do_SUBST_MODE (rtx *into, enum machine_m } #define SUBST_MODE(INTO, NEWVAL) do_SUBST_MODE(&(INTO), (NEWVAL)) + +/* Similar to SUBST, but NEWVAL is a LOG_LINKS expression. */ + +static void +do_SUBST_LINK (rtx *into, rtx newval) +{ + struct undo *buf; + rtx oldval = *into; + + if (oldval == newval) + return; + + if (undobuf.frees) + buf = undobuf.frees, undobuf.frees = buf->next; + else + buf = XNEW (struct undo); + + buf->kind = UNDO_RTX; + buf->where.r = into; + buf->old_contents.r = oldval; + *into = newval; + + buf->next = undobuf.undos, undobuf.undos = buf; +} + +#define SUBST_LINK(oldval, newval) do_SUBST_LINK (&oldval, newval) + /* Subroutine of try_combine. Determine whether the combine replacement patterns NEWPAT, NEWI2PAT and NEWOTHERPAT are cheaper according to @@ -2867,6 +2894,7 @@ try_combine (rtx i3, rtx i2, rtx i1, rtx SUBST (PATTERN (i2), XVECEXP (PATTERN (i2), 0, 0)); SUBST (XEXP (SET_SRC (PATTERN (i2)), 0), SET_DEST (PATTERN (i1))); + SUBST_LINK (LOG_LINKS (i2), alloc_INSN_LIST (i1, LOG_LINKS (i2))); } } #endif