From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,d368012aff3bdc04,start X-Google-Attributes: gidfee84,public From: Joerg Czeranski Subject: DEC C -tune ev6 optimization bug Date: 1999/06/14 Message-ID: <5vWGOC4gy$0aG$1@joerch.org>#1/1 X-Deja-AN: 489287787 Organization: Joerch Software Newsgroups: comp.unix.osf.osf1 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