From 82fa5f8aa727db4ab9f172ddc454fc25325b82ca Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Thu, 18 Mar 2010 06:10:49 -0700 Subject: [PATCH] Remove the REG_EQUAL note if we don't know its invariant status. gcc/ 2010-03-18 Steven Bosscher Eric Botcazou PR rtl-optimization/43360 * loop-invariant.c (move_invariant_reg): Remove the REG_EQUAL note if we don't know its invariant status. gcc/testsuite/ 2010-03-18 H.J. Lu PR rtl-optimization/43360 * gcc.dg/torture/pr43360.c: New. From-SVN: r157539 --- gcc/ChangeLog | 7 +++++++ gcc/loop-invariant.c | 18 ++++++++++-------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/torture/pr43360.c | 20 ++++++++++++++++++++ 4 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr43360.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0e9101d4fea6..a4254a869695 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2010-03-18 Steven Bosscher + Eric Botcazou + + PR rtl-optimization/43360 + * loop-invariant.c (move_invariant_reg): Remove the REG_EQUAL + note if we don't know its invariant status. + 2010-03-18 Michael Matz PR tree-optimization/43402 diff --git a/gcc/loop-invariant.c b/gcc/loop-invariant.c index 03f0a13baa06..57973c195233 100644 --- a/gcc/loop-invariant.c +++ b/gcc/loop-invariant.c @@ -1423,14 +1423,16 @@ move_invariant_reg (struct loop *loop, unsigned invno) emit_insn_after (gen_move_insn (dest, reg), inv->insn); reorder_insns (inv->insn, inv->insn, BB_END (preheader)); - /* If there is a REG_EQUAL note on the insn we just moved, and - insn is in a basic block that is not always executed, the note - may no longer be valid after we move the insn. - Note that uses in REG_EQUAL notes are taken into account in - the computation of invariants. Hence it is safe to retain the - note even if the note contains register references. */ - if (! inv->always_executed - && (note = find_reg_note (inv->insn, REG_EQUAL, NULL_RTX))) + /* If there is a REG_EQUAL note on the insn we just moved, and the + insn is in a basic block that is not always executed or the note + contains something for which we don't know the invariant status, + the note may no longer be valid after we move the insn. Note that + uses in REG_EQUAL notes are taken into account in the computation + of invariants, so it is safe to retain the note even if it contains + register references for which we know the invariant status. */ + if ((note = find_reg_note (inv->insn, REG_EQUAL, NULL_RTX)) + && (!inv->always_executed + || !check_maybe_invariant (XEXP (note, 0)))) remove_note (inv->insn, note); } else diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bc56c911ec3d..4b69cb7f5799 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-03-18 H.J. Lu + + PR rtl-optimization/43360 + * gcc.dg/torture/pr43360.c: New. + 2010-03-18 Michael Matz PR tree-optimization/43402 diff --git a/gcc/testsuite/gcc.dg/torture/pr43360.c b/gcc/testsuite/gcc.dg/torture/pr43360.c new file mode 100644 index 000000000000..9ed9872db263 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr43360.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ + +int l_5_5_2 = 4; +int g_3[1][1]; + +void func_1 (void) +{ + for (g_3[0][0] = 1; g_3[0][0] < 8; g_3[0][0] += 7) { + int *l_6 = &g_3[0][0]; + *l_6 = l_5_5_2; + } +} + +int main (void) +{ + func_1 (); + if (g_3[0][0] != 11) + __builtin_abort (); + return 0; +} -- 2.47.2