aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2002-02-04 10:40:57 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2002-02-04 10:40:57 +0100
commitfa85240399ae47b61db39f956ce498aecac4daf3 (patch)
tree5e75107a668fd1a7d17bce35fea894d0220c5b85
parent9780c24faf10be83aaab8fef66a6390bc75e40b1 (diff)
downloadgcc-fa85240399ae47b61db39f956ce498aecac4daf3.zip
gcc-fa85240399ae47b61db39f956ce498aecac4daf3.tar.gz
gcc-fa85240399ae47b61db39f956ce498aecac4daf3.tar.bz2
combine.c (recog_for_combine): Create a dummy insn with PATTERN pat for recog.
* combine.c (recog_for_combine): Create a dummy insn with PATTERN pat for recog. * gcc.dg/20020201-4.c: New test. From-SVN: r49473
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/combine.c17
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/20020201-4.c16
4 files changed, 34 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1b6153b..825d95e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2002-02-04 Jakub Jelinek <jakub@redhat.com>
+
+ * combine.c (recog_for_combine): Create a dummy insn with PATTERN
+ pat for recog.
+
2002-02-04 Hartmut Penner <hpenner@de.ibm.com>
* varasm.c (decode_rtx_const): Allow unspec (symbol_ref) in
diff --git a/gcc/combine.c b/gcc/combine.c
index 47ac3a8..25b4d63 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -9590,7 +9590,7 @@ recog_for_combine (pnewpat, insn, pnotes)
int num_clobbers_to_add = 0;
int i;
rtx notes = 0;
- rtx old_notes;
+ rtx dummy_insn;
/* If PAT is a PARALLEL, check to see if it contains the CLOBBER
we use to indicate that something didn't match. If we find such a
@@ -9601,11 +9601,13 @@ recog_for_combine (pnewpat, insn, pnotes)
&& XEXP (XVECEXP (pat, 0, i), 0) == const0_rtx)
return -1;
- /* Remove the old notes prior to trying to recognize the new pattern. */
- old_notes = REG_NOTES (insn);
- REG_NOTES (insn) = 0;
+ /* *pnewpat does not have to be actual PATTERN (insn), so make a dummy
+ instruction for pattern recognition. */
+ dummy_insn = shallow_copy_rtx (insn);
+ PATTERN (dummy_insn) = pat;
+ REG_NOTES (dummy_insn) = 0;
- insn_code_number = recog (pat, insn, &num_clobbers_to_add);
+ insn_code_number = recog (pat, dummy_insn, &num_clobbers_to_add);
/* If it isn't, there is the possibility that we previously had an insn
that clobbered some register as a side effect, but the combined
@@ -9630,15 +9632,14 @@ recog_for_combine (pnewpat, insn, pnotes)
if (pos == 1)
pat = XVECEXP (pat, 0, 0);
- insn_code_number = recog (pat, insn, &num_clobbers_to_add);
+ PATTERN (dummy_insn) = pat;
+ insn_code_number = recog (pat, dummy_insn, &num_clobbers_to_add);
}
/* Recognize all noop sets, these will be killed by followup pass. */
if (insn_code_number < 0 && GET_CODE (pat) == SET && set_noop_p (pat))
insn_code_number = NOOP_MOVE_INSN_CODE, num_clobbers_to_add = 0;
- REG_NOTES (insn) = old_notes;
-
/* If we had any clobbers to add, make a new pattern than contains
them. Then check to make sure that all of them are dead. */
if (num_clobbers_to_add)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8a078a4..fe11a62 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2002-02-04 Jakub Jelinek <jakub@redhat.com>
+
+ * gcc.dg/20020201-4.c: New test.
+
2002-02-04 Ben Elliston <bje@redhat.com>
* lib/gcc.exp (gcc_init): Check that the need_status_wrapper
diff --git a/gcc/testsuite/gcc.dg/20020201-4.c b/gcc/testsuite/gcc.dg/20020201-4.c
new file mode 100644
index 0000000..3c83fe7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/20020201-4.c
@@ -0,0 +1,16 @@
+/* This testcase failed because recog_for_combine used to pass a different
+ pattern than contained in insn to recog. */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fssa -fssa-ccp" } */
+/* { dg-options "-O2 -march=i686 -fssa -fssa-ccp" { target i?86-*-* } } */
+
+extern int bar (char *);
+
+int
+foo (void)
+{
+ char b[512];
+
+ bar (b);
+ return __builtin_strlen (b);
+}