From a5a4add7aa2b78c3c7f48b173e24944439d82992 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 28 Nov 2016 23:51:29 +0100 Subject: [PATCH] re PR middle-end/78540 (ICE: in df_refs_verify, at df-scan.c:4062 with -O -march=core2) PR middle-end/78540 * rtl.h (remove_reg_equal_equiv_notes): Return bool instead of void. * rtlanal.c (remove_reg_equal_equiv_notes): Return true if any note has been removed. * postreload.c (reload_combine_recognize_pattern): If remove_reg_equal_equiv_notes returns true, call df_notes_rescan. * gcc.dg/pr78540.c: New test. From-SVN: r242937 --- gcc/ChangeLog | 9 +++++++++ gcc/postreload.c | 9 +++++---- gcc/rtl.h | 2 +- gcc/rtlanal.c | 12 +++++++++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr78540.c | 27 +++++++++++++++++++++++++++ 6 files changed, 56 insertions(+), 8 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr78540.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 12a717ea7f8..f62f7cb95cb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2016-11-28 Jakub Jelinek + + PR middle-end/78540 + * rtl.h (remove_reg_equal_equiv_notes): Return bool instead of void. + * rtlanal.c (remove_reg_equal_equiv_notes): Return true if any + note has been removed. + * postreload.c (reload_combine_recognize_pattern): If + remove_reg_equal_equiv_notes returns true, call df_notes_rescan. + 2016-11-28 Martin Sebor PR middle-end/78520 diff --git a/gcc/postreload.c b/gcc/postreload.c index fcb6bc4bd50..539ad33b6c3 100644 --- a/gcc/postreload.c +++ b/gcc/postreload.c @@ -1192,10 +1192,11 @@ reload_combine_recognize_pattern (rtx_insn *insn) /* Delete the reg-reg addition. */ delete_insn (insn); - if (reg_state[regno].offset != const0_rtx) - /* Previous REG_EQUIV / REG_EQUAL notes for PREV - are now invalid. */ - remove_reg_equal_equiv_notes (prev); + if (reg_state[regno].offset != const0_rtx + /* Previous REG_EQUIV / REG_EQUAL notes for PREV + are now invalid. */ + && remove_reg_equal_equiv_notes (prev)) + df_notes_rescan (prev); reg_state[regno].use_index = RELOAD_COMBINE_MAX_USES; return true; diff --git a/gcc/rtl.h b/gcc/rtl.h index 660d381939d..5fde6989216 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -3057,7 +3057,7 @@ extern void add_int_reg_note (rtx_insn *, enum reg_note, int); extern void add_shallow_copy_of_reg_note (rtx_insn *, rtx); extern rtx duplicate_reg_note (rtx); extern void remove_note (rtx_insn *, const_rtx); -extern void remove_reg_equal_equiv_notes (rtx_insn *); +extern bool remove_reg_equal_equiv_notes (rtx_insn *); extern void remove_reg_equal_equiv_notes_for_regno (unsigned int); extern int side_effects_p (const_rtx); extern int volatile_refs_p (const_rtx); diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c index 17dbb1eaeb1..4e4eb2ef345 100644 --- a/gcc/rtlanal.c +++ b/gcc/rtlanal.c @@ -2351,22 +2351,28 @@ remove_note (rtx_insn *insn, const_rtx note) } } -/* Remove REG_EQUAL and/or REG_EQUIV notes if INSN has such notes. */ +/* Remove REG_EQUAL and/or REG_EQUIV notes if INSN has such notes. + Return true if any note has been removed. */ -void +bool remove_reg_equal_equiv_notes (rtx_insn *insn) { rtx *loc; + bool ret = false; loc = ®_NOTES (insn); while (*loc) { enum reg_note kind = REG_NOTE_KIND (*loc); if (kind == REG_EQUAL || kind == REG_EQUIV) - *loc = XEXP (*loc, 1); + { + *loc = XEXP (*loc, 1); + ret = true; + } else loc = &XEXP (*loc, 1); } + return ret; } /* Remove all REG_EQUAL and REG_EQUIV notes referring to REGNO. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e4dff3c3e09..a63953ca891 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-11-28 Jakub Jelinek + + PR middle-end/78540 + * gcc.dg/pr78540.c: New test. + 2016-11-28 Martin Sebor PR middle-end/78520 diff --git a/gcc/testsuite/gcc.dg/pr78540.c b/gcc/testsuite/gcc.dg/pr78540.c new file mode 100644 index 00000000000..68bd9a449c4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr78540.c @@ -0,0 +1,27 @@ +/* PR middle-end/78540 */ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O2 -Wno-psabi" } */ +/* { dg-additional-options "-march=core2" { target i?86-*-* x86_64-*-* } } */ + +typedef unsigned __int128 V __attribute__ ((vector_size (64))); +V g; + +static inline V +foo (V a) +{ + V b, c; + c[0] = 0; + a += 2281559097; + c ^= 0; + b[0] = 0; + return 1 + c + b + a; +} + +V +bar () +{ + V a = g, b = g; + a[1] ^= 1; + b[foo (a)[0] & 3] |= 1; + return b; +} -- 2.30.2