* DEC C -tune ev6 optimization bug
@ 1999-06-14 4:00 Joerg Czeranski
1999-06-14 4:00 ` Jeff Sullivan
0 siblings, 1 reply; 2+ messages in thread
From: Joerg Czeranski @ 1999-06-14 4:00 UTC (permalink / raw)
Another compiler bug found while compiling Objective Caml :-)
The source for reproducing the problem:
-------------------- snip here --------------------
#pragma noinline fill /* force main to call fill() */
void fill(unsigned long n, long *a)
{
unsigned long i;
for (i = 0; i < n; i++) a[i] = 0;
}
int main(void)
{
static long a[4];
fill(4, a);
return 0;
}
-------------------- snip here --------------------
I compiled it as "cc -std1 -fast -tune ev6 source.c" and with
"cc.alt" with the same options on a factory installed DU4.0E
with compiler versions:
DEC C V5.8-009 on Digital UNIX V4.0 (Rev. 1091)
DEC C V6.0-007 (cc.alt) on Digital UNIX V4.0 (Rev. 1091)
The type of "n" (unsigned long) seems to confuse the optimizer -
it seems to work with "int n", "unsigned n", "long n", but I didn't
test it thoroughly.
It uses wh64 instructions (nice optimization BTW) but miscalculates
the bound as &a[(1L << 32) + n] (with the lowest 6 bits cleared)
instead of &a[n].
This leads to cache corruption for memory after the array "a".
"long *volatile a" disables the use of wh64 and can be used to work
around this problem.
I didn't find a patch for this problem in patch kit 1.
joerch
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: DEC C -tune ev6 optimization bug
1999-06-14 4:00 DEC C -tune ev6 optimization bug Joerg Czeranski
@ 1999-06-14 4:00 ` Jeff Sullivan
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Sullivan @ 1999-06-14 4:00 UTC (permalink / raw)
Joerg Czeranski wrote:
>
> It uses wh64 instructions (nice optimization BTW) but miscalculates
> the bound as &a[(1L << 32) + n] (with the lowest 6 bits cleared)
> instead of &a[n].
> This leads to cache corruption for memory after the array "a".
Yes, this is a known problem that wasn't easily reproduced on
pre-ev6 hardware. Hence, it has existed for a while, but had
gone largely undetected until recently. Your diagnosis above
is a very good description of the problem.
The good news is that the problem has been fixed and is expected
to be in our future compilers. We expect that this will be fixed
the patch compilers for V4.0E,F and V5.0.
We also expect that this will be fixed in our next Developers'
Toolkit compiler (EFT3). For more information, see
http://www.unix.digital.com/developerstoolkit/
Thanks,
-Jeff
--
Jeff Sullivan | Compaq Computer Corp | mailto:jps@zk3.dec.com
Compaq C/C++ | Nashua, NH ZK3-2X23 | Jeff.Sullivan@compaq.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1999-06-14 4:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-06-14 4:00 DEC C -tune ev6 optimization bug Joerg Czeranski
1999-06-14 4:00 ` Jeff Sullivan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox