From: Rafael Avila de Espindola Date: Wed, 28 May 2008 16:20:25 +0000 (+0000) Subject: see.c (see_def_extension_not_merged): Use copy_rtx_if_shared to avoid invalid sharing. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5a976da002caf3838a1f986098ce655fb881efb8;p=gcc.git see.c (see_def_extension_not_merged): Use copy_rtx_if_shared to avoid invalid sharing. 2008-05-28 Rafael Espindola * see.c (see_def_extension_not_merged): Use copy_rtx_if_shared to avoid invalid sharing. 2008-05-28 Rafael Espindola * gcc.dg/20080528-1.c: New test. From-SVN: r136115 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 43e61a636b0..fe82a48d1bd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2008-05-28 Rafael Espindola + + * see.c (see_def_extension_not_merged): Use copy_rtx_if_shared to avoid + invalid sharing. + 2008-05-28 Richard Guenther PR tree-optimization/36339 diff --git a/gcc/see.c b/gcc/see.c index dce51691cbe..5084b976559 100644 --- a/gcc/see.c +++ b/gcc/see.c @@ -2554,6 +2554,17 @@ see_def_extension_not_merged (struct see_ref_s *curr_ref_s, rtx def_se) /* The manipulation succeeded. Store the new manipulated reference. */ + /* It is possible for dest_reg to appear multiple times in ref_copy. In this + case, ref_copy now has invalid sharing. Copying solves the problem. + We don't use copy_rtx as an optimization for the common case (no sharing). + We can't just use copy_rtx_if_shared since it does nothing on INSNs. + Another possible solution would be to make validate_replace_rtx_1 + public and use it instead of replace_rtx. */ + reset_used_flags (PATTERN (ref_copy)); + reset_used_flags (REG_NOTES (ref_copy)); + PATTERN (ref_copy) = copy_rtx_if_shared (PATTERN (ref_copy)); + REG_NOTES (ref_copy) = copy_rtx_if_shared (REG_NOTES (ref_copy)); + /* Try to simplify the new manipulated insn. */ validate_simplify_insn (ref_copy); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7533e378718..c548a7d1828 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2008-05-28 Rafael Espindola + + * gcc.dg/20080528-1.c: New test. + 2008-05-28 Arnaud Charlet * gnat.dg/old_errors.adb, gnat.dg/deep_old.adb: Adjust. diff --git a/gcc/testsuite/gcc.dg/20080528-1.c b/gcc/testsuite/gcc.dg/20080528-1.c new file mode 100644 index 00000000000..9fe978051eb --- /dev/null +++ b/gcc/testsuite/gcc.dg/20080528-1.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fsee" } */ + +unsigned long g(int a, int b) { + return a / b; +} +unsigned long f(long int a) { + return g(a, 1<<13); +}