summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2005-03-10 21:26:12 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2005-03-10 21:26:12 +0000
commit1d4e5a23d3038a2e61c2a7006c5cc806a7a2c217 (patch)
tree9cfc0de0e97b1d9ecbd24b272c39d0c35a91f478
parent2a1b4a2aa4917d356b0b828dedcf60cc4c5315ef (diff)
downloadgcc-1d4e5a23d3038a2e61c2a7006c5cc806a7a2c217.tar.gz
PR target/20322
* combine.c (try_combine): If recog_for_combine added CLOBBERs to NEWI2PAT, fail to combine if they are used by NEWPAT. * gcc.dg/20050307-1.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@96260 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/combine.c14
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/20050307-1.c52
4 files changed, 77 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 03b1ef519aa..ff1e60be294 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2005-03-10 Jakub Jelinek <jakub@redhat.com>
+
+ PR target/20322
+ * combine.c (try_combine): If recog_for_combine added CLOBBERs
+ to NEWI2PAT, fail to combine if they are used by NEWPAT.
+
2005-03-10 Aldy Hernandez <aldyh@redhat.com>
* doc/invoke.texi: Add 8540 to list of cpus in rs6000 cpu section.
diff --git a/gcc/combine.c b/gcc/combine.c
index 0fc1f5f4283..ae20c51caaf 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -2417,6 +2417,20 @@ try_combine (rtx i3, rtx i2, rtx i1, int *new_direct_jump_p)
SUBST (*split, newdest);
i2_code_number = recog_for_combine (&newi2pat, i2, &new_i2_notes);
+ /* recog_for_combine might have added CLOBBERs to newi2pat.
+ Make sure NEWPAT does not depend on the clobbered regs. */
+ if (GET_CODE (newi2pat) == PARALLEL)
+ for (i = XVECLEN (newi2pat, 0) - 1; i >= 0; i--)
+ if (GET_CODE (XVECEXP (newi2pat, 0, i)) == CLOBBER)
+ {
+ rtx reg = XEXP (XVECEXP (newi2pat, 0, i), 0);
+ if (reg_overlap_mentioned_p (reg, newpat))
+ {
+ undo_all ();
+ return 0;
+ }
+ }
+
/* If the split point was a MULT and we didn't have one before,
don't use one now. */
if (i2_code_number >= 0 && ! (split_code == MULT && ! have_mult))
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8454c08cc60..082f18a33e6 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2005-03-10 Jakub Jelinek <jakub@redhat.com>
+
+ PR target/20322
+ * gcc.dg/20050307-1.c: New test.
+
2005-03-10 Nathan Sidwell <nathan@codesourcery.com>
PR c++/20375
diff --git a/gcc/testsuite/gcc.dg/20050307-1.c b/gcc/testsuite/gcc.dg/20050307-1.c
new file mode 100644
index 00000000000..0e8dac69a65
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/20050307-1.c
@@ -0,0 +1,52 @@
+/* PR target/20322 */
+
+extern void abort (void);
+
+typedef unsigned long T;
+typedef struct
+{
+ T a, b;
+ unsigned char c, d;
+} S;
+
+#define M (sizeof (T) * 4)
+
+S __attribute__((noinline))
+foo (T x, T y)
+{
+ S e;
+ T f[2], g;
+
+ e.b = (x & (~(T) 0 >> M)) * (y & (~(T) 0 >> M));
+ e.a = (x >> M) * (y >> M);
+
+ f[0] = (x & (~(T) 0 >> M)) * (y >> M);
+ f[1] = (x >> M) * (y & (~(T) 0 >> M));
+
+ g = e.b;
+ e.b += (f[0] & (~(T) 0 >> M)) << M;
+ if (e.b < g)
+ e.a++;
+
+ g = e.b;
+ e.b += (f[1] & (~(T) 0 >> M)) << M;
+ if (e.b < g)
+ e.a++;
+
+ e.a += (f[0] >> M);
+ e.a += (f[1] >> M);
+ e.c = 1;
+ e.d = 0;
+
+ return e;
+}
+
+int
+main (void)
+{
+ T x = 1UL << (M * 2 - 1);
+ S y = foo (1, x);
+ if (y.a || y.b != x || y.c != 1 || y.d)
+ abort ();
+ return 0;
+}