2007-10-11 Jakub Jelinek PR rtl-optimization/33644 * dce.c (delete_unmarked_insns): Don't move REG_LIBCALL note to an insn without REG_LIBCALL_ID note. * gcc.dg/pr33644.c: New test. --- gcc/dce.c.jj 2007-10-08 10:45:03.000000000 +0200 +++ gcc/dce.c 2007-10-11 20:33:47.000000000 +0200 @@ -278,6 +278,10 @@ delete_unmarked_insns (void) rtx new_libcall_insn = next_real_insn (insn); rtx retval_note = find_reg_note (XEXP (note, 0), REG_RETVAL, NULL_RTX); + while (new_libcall_insn != XEXP (note, 0) + && !find_reg_note (new_libcall_insn, REG_LIBCALL_ID, + NULL_RTX)) + new_libcall_insn = next_real_insn (new_libcall_insn); REG_NOTES (new_libcall_insn) = gen_rtx_INSN_LIST (REG_LIBCALL, XEXP (note, 0), REG_NOTES (new_libcall_insn)); --- gcc/testsuite/gcc.dg/pr33644.c.jj 2007-10-11 20:29:20.000000000 +0200 +++ gcc/testsuite/gcc.dg/pr33644.c 2007-10-11 20:13:21.000000000 +0200 @@ -0,0 +1,19 @@ +/* PR rtl-optimization/33644 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftrapv" } */ + +extern char *bar (const char *); +int *m, *b; + +void +foo (void) +{ + int *mv; + int p; + char a[17]; + + p = bar (a) - a; + for (mv = m; mv < b; mv++) + if (p && ((*mv & 7) != p)) + *mv = 0; +}