From 05969da4c37b0c4120a5ac7b7a803f3f98f972af Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Sun, 18 Nov 2007 20:22:35 +0100 Subject: [PATCH] re PR rtl-optimization/34132 (ICE: internal consistency failure (invalid rtl sharing found in the insn)) PR rtl-optimization/34132 * gcse.c (try_replace_reg): Avoid rtx sharing between REG_EQUAL note and insn. * gcc.c-torture/compile/20071118-1.c: New test. From-SVN: r130275 --- gcc/ChangeLog | 4 ++++ gcc/gcse.c | 3 ++- gcc/testsuite/ChangeLog | 5 +++++ .../gcc.c-torture/compile/20071118-1.c | 17 +++++++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/20071118-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e3b5f8483ba..cf958d14a91 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2007-11-18 Jakub Jelinek + PR rtl-optimization/34132 + * gcse.c (try_replace_reg): Avoid rtx sharing between REG_EQUAL note + and insn. + PR middle-end/33335 * optabs.h (optab_table): Change type to struct optab from optab. (convert_optab_table): Similarly. diff --git a/gcc/gcse.c b/gcc/gcse.c index c5e8c7b44f5..84c0994753d 100644 --- a/gcc/gcse.c +++ b/gcc/gcse.c @@ -2665,7 +2665,8 @@ try_replace_reg (rtx from, rtx to, rtx insn) with our replacement. */ if (note != 0 && REG_NOTE_KIND (note) == REG_EQUAL) set_unique_reg_note (insn, REG_EQUAL, - simplify_replace_rtx (XEXP (note, 0), from, to)); + simplify_replace_rtx (XEXP (note, 0), from, + copy_rtx (to))); if (!success && set && reg_mentioned_p (from, SET_SRC (set))) { /* If above failed and this is a single set, try to simplify the source of diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6d3bd10edf0..cf4759f897d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-11-18 Jakub Jelinek + + PR rtl-optimization/34132 + * gcc.c-torture/compile/20071118-1.c: New test. + 2007-11-18 Paul Thomas PR fortran/31608 diff --git a/gcc/testsuite/gcc.c-torture/compile/20071118-1.c b/gcc/testsuite/gcc.c-torture/compile/20071118-1.c new file mode 100644 index 00000000000..d093d3fd860 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/20071118-1.c @@ -0,0 +1,17 @@ +/* PR rtl-optimization/34132 */ +/* Testcase by Martin Michlmayr */ + +static char *m = "%s%u.msg"; +extern void bar (int, const char *); +void foo (short x, int y, int z) +{ + if (x == 0) + { + bar (y, m); + z = 1; + } + else if (x == 1) + z = 0; + bar (y, m); + bar (z, "%d"); +}