* Re: [davidm@azstarnet.com: Re: gcc-2.7.1 bug]
[not found] <199603252243.PAA32288@koala.azstarnet.com>
@ 1996-03-26 6:48 ` Richard Henderson
0 siblings, 0 replies; 3+ messages in thread
From: Richard Henderson @ 1996-03-26 6:48 UTC (permalink / raw)
On Mon, 25 Mar 1996 David Mosberger-Tang <davidm@AZStarNet.com> wrote:
> Here is a detailed description (and a small test program that
> reproduces the problem) of the gcc bug I mentioned earlier today.
> Richard Kenner determined that the latest gcc still has this problem.
> It's apparently due to a bug in `combine' (not the instruction
> scheduler as I guessed). Since Richard won't be able to fix it
> immediately, I thought I'd forward this to the mailing lists so people
> know what exactly goes wrong. Of course, if somebody could find a
> fix, I'm sure Richard wouldn't mind receiving a patch either... :-)
It is indeed in the combiner. The problem in this example is where
insns 52, 25, and 24 are combined into two insns. Unfortunately,
the new insn 25 overwrites $20, used in insn 48.
My fix is to notice when we are going to successfully combine
into two insns, and check to see if the destination of the
earlier insn is used between the two insns. If so, we cannot
do the combination.
For completeness, the test function is reproduced along with
the patch.
r~
==============================
long
XGetRGBColormaps (dpy, w, stdcmap, count, property)
void *dpy;
long w;
long **stdcmap;
int *count;
long property;
{
long *data = 0;
int actual_format;
unsigned long nitems;
unsigned long actual_type, leftover;
if (XGetWindowProperty (dpy, w, property, 0L, 1000000L, 0,
27, &actual_type, &actual_format,
&nitems, &leftover, (unsigned char **)&data)
!= 0)
return 0;
return 1;
}
==============================
Tue Mar 26 00:39:05 1996 Richard Henderson <rth@tamu.edu>
* combine.c (try_combine): When three insns have been
merged into two, fail if the destination of the new
i2 pattern is live between i2 and i3.
Index: combine.c
===================================================================
RCS file: /home/richard/Repository/cygnus/gcc/combine.c,v
retrieving revision 1.1.1.1
diff -c -p -r1.1.1.1 combine.c
*** combine.c 1996/03/26 02:30:31 1.1.1.1
--- combine.c 1996/03/26 06:37:10
*************** try_combine (i3, i2, i1)
*** 2077,2082 ****
--- 2077,2091 ----
undobuf.other_insn, NULL_RTX, NULL_RTX, NULL_RTX);
}
+ /* If we are modifying i2, make sure its SET won't overwrite
+ something that's still live through i3. */
+ if (newi2pat && GET_CODE(newi2pat) == SET
+ && reg_used_between_p (SET_DEST (newi2pat), i2, i3))
+ {
+ undo_all ();
+ return 0;
+ }
+
/* We now know that we can do this combination. Merge the insns and
update the status of registers and LOG_LINKS. */
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [davidm@azstarnet.com: Re: gcc-2.7.1 bug]
@ 1996-03-26 10:36 Richard Kenner
0 siblings, 0 replies; 3+ messages in thread
From: Richard Kenner @ 1996-03-26 10:36 UTC (permalink / raw)
I think there's more to it than this. Note that there's a missing REG_DEAD
note on the new last use of $20 before it's reloaded as a parameter to
the called function.
I'd start with that; it may point to a more precise fix.
However, your fix will definately work and looks safe.
Thanks for investigating this far. At least there's a temporary
solution to this problem.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [davidm@azstarnet.com: Re: gcc-2.7.1 bug]
@ 1996-03-25 22:43 David Mosberger-Tang
0 siblings, 0 replies; 3+ messages in thread
From: David Mosberger-Tang @ 1996-03-25 22:43 UTC (permalink / raw)
Here is a detailed description (and a small test program that
reproduces the problem) of the gcc bug I mentioned earlier today.
Richard Kenner determined that the latest gcc still has this problem.
It's apparently due to a bug in `combine' (not the instruction
scheduler as I guessed). Since Richard won't be able to fix it
immediately, I thought I'd forward this to the mailing lists so people
know what exactly goes wrong. Of course, if somebody could find a
fix, I'm sure Richard wouldn't mind receiving a patch either... :-)
--david
------- Start of forwarded message -------
Return-Path: davidm
Date: Mon, 25 Mar 1996 13:01:18 -0700
From: David Mosberger-Tang <davidm@azstarnet.com>
To: kenner@vlsi1.ultra.nyu.edu, davidm
In-reply-to: <9603251224.AA13984@vlsi1.ultra.nyu.edu>
(kenner@vlsi1.ultra.nyu.edu)
Subject: Re: gcc-2.7.1 bug
Just ran into another bug. This time it's a code generation bug (it
looks like the instruction scheduler is overly aggressive). Given
the code:
long
XGetRGBColormaps (dpy, w, stdcmap, count, property)
void *dpy;
long w;
long **stdcmap;
int *count;
long property;
{
long *data = 0;
int actual_format;
unsigned long nitems;
unsigned long actual_type, leftover;
if (XGetWindowProperty (dpy, w, property, 0L, 1000000L, 0,
27, &actual_type, &actual_format,
&nitems, &leftover, (unsigned char **)&data)
!= 0)
return 0;
return 1;
}
If I translate this with gcc-2.7.1 with options -O2 -S, I get:
.align 3
.globl XGetRGBColormaps
.ent XGetRGBColormaps
XGetRGBColormaps:
ldgp $29,0($27)
XGetRGBColormaps..ng:
lda $30,-112($30)
.frame $30,112,$26,0
stq $26,48($30)
.mask 0x4000000,-64
.prologue 1
lda $20,16960 # <--------- overwrites a4
bis $31,27,$1
addq $30,72,$2
addq $30,80,$3
stq $31,96($30)
addq $30,88,$4
stq $1,0($30)
addq $30,96,$1
addq $30,64,$5
stq $5,8($30)
bis $31,$31,$19
stq $2,16($30)
bis $31,$31,$21
stq $3,24($30)
bis $20,$20,$18 # <- attempt to move old value of a4 into a2
stq $4,32($30)
ldah $20,15($20) # <- finish loading constant 100000L into a4
stq $1,40($30)
jsr $26,XGetWindowProperty
So it looks like the "lda $20,16960" instruction incorrectly got moved
before the instruction that moves a4 into a2.
Correct code is generated if -O is used.
Can you reproduce this?
--david
------- End of forwarded message -------
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1996-03-26 10:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <199603252243.PAA32288@koala.azstarnet.com>
1996-03-26 6:48 ` [davidm@azstarnet.com: Re: gcc-2.7.1 bug] Richard Henderson
1996-03-26 10:36 Richard Kenner
-- strict thread matches above, loose matches on Subject: below --
1996-03-25 22:43 David Mosberger-Tang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox