------- Comment #10 from zadeck at naturalbridge dot com 2007-10-07 21:57
-------
Subject: Re: [4.3 Regression] Revision 128957
miscompiles 481.wrf
This patch fixes pr33669.
The failure only happens if you have a block with 2 or more uses of a
multiword pseudo register that is local to this block and has been
allocated by local_alloc. The uses must be in a particular form: the
last use must be a subreg use that only used some of the hard registers and
a previous non subreg use of the multiword register.
When all of this happens, the code did not properly expand this to a
whole multiregister when the second to last use is encountered in the
backwards scan.
I.e. a lot of things have to happen to get this to fail.
I have tested this patch on ia-64, x86-{64,32} and ppc-32.
Ok for commit?
Kenny
2007-10-07 Kenneth Zadeck <[EMAIL PROTECTED]>
PR middle-end/33669
* ra-conflict.c (record_one_conflict_between_regnos,
set_conflicts_for_earlyclobber, global_conflicts): Improved logging.
(global_conflicts): Removed incorrect check.
2007-10-07 Kenneth Zadeck <[EMAIL PROTECTED]>
PR middle-end/33669
* gcc.c-torture/execute/pr33669.c: New.
Index: ra-conflict.c
===================================================================
--- ra-conflict.c (revision 129053)
+++ ra-conflict.c (working copy)
@@ -196,7 +196,7 @@ record_one_conflict_between_regnos (enum
int allocno2 = reg_allocno[r2];
if (dump_file)
- fprintf (dump_file, " rocbr adding %d<=>%d\n", r1, r2);
+ fprintf (dump_file, " rocbr adding %d<=>%d\n", r1, r2);
if (allocno1 >= 0 && allocno2 >= 0)
set_conflict (allocno1, allocno2);
@@ -401,9 +401,6 @@ set_conflicts_for_earlyclobber (rtx insn
recog_data.operand[use +
1]);
}
}
-
- if (dump_file)
- fprintf (dump_file, " finished early clobber conflicts.\n");
}
@@ -984,7 +981,7 @@ global_conflicts (void)
allocnum, renumber);
}
- else if (!sparseset_bit_p (allocnos_live, allocnum))
+ else
{
if (dump_file)
fprintf (dump_file, " dying pseudo\n");
@@ -1071,6 +1068,8 @@ global_conflicts (void)
FIXME: We should consider either adding a new kind of
clobber, or adding a flag to the clobber distinguish
these two cases. */
+ if (dump_file && VEC_length (df_ref_t, clobbers))
+ fprintf (dump_file, " clobber conflicts\n");
for (k = VEC_length (df_ref_t, clobbers) - 1; k >= 0; k--)
{
struct df_ref *def = VEC_index (df_ref_t, clobbers, k);
@@ -1132,6 +1131,8 @@ global_conflicts (void)
if (GET_CODE (PATTERN (insn)) == PARALLEL && multiple_sets
(insn))
{
int j;
+ if (dump_file)
+ fprintf (dump_file, " multiple sets\n");
for (j = VEC_length (df_ref_t, dying_regs) - 1; j >= 0; j--)
{
int used_in_output = 0;
Index: testsuite/gcc.c-torture/execute/pr33669.c
===================================================================
--- testsuite/gcc.c-torture/execute/pr33669.c (revision 0)
+++ testsuite/gcc.c-torture/execute/pr33669.c (revision 0)
@@ -0,0 +1,40 @@
+extern void abort (void);
+
+typedef struct foo_t
+{
+ unsigned int blksz;
+ unsigned int bf_cnt;
+} foo_t;
+
+#define _RNDUP(x, unit) ((((x) + (unit) - 1) / (unit)) * (unit))
+#define _RNDDOWN(x, unit) ((x) - ((x)%(unit)))
+
+long long
+foo (foo_t *const pxp, long long offset, unsigned int extent)
+{
+ long long blkoffset = _RNDDOWN(offset, (long long )pxp->blksz);
+ unsigned int diff = (unsigned int)(offset - blkoffset);
+ unsigned int blkextent = _RNDUP(diff + extent, pxp->blksz);
+
+ if (pxp->blksz < blkextent)
+ return -1LL;
+
+ if (pxp->bf_cnt > pxp->blksz)
+ pxp->bf_cnt = pxp->blksz;
+
+ return blkoffset;
+}
+
+int
+main ()
+{
+ foo_t x;
+ long long xx;
+
+ x.blksz = 8192;
+ x.bf_cnt = 0;
+ xx = foo (&x, 0, 4096);
+ if (xx != 0LL)
+ abort ();
+ return 0;
+}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33669