From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14389 invoked by alias); 1 Jun 2002 13:16:05 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 14352 invoked by uid 71); 1 Jun 2002 13:16:02 -0000 Resent-Date: 1 Jun 2002 13:16:02 -0000 Resent-Message-ID: <20020601131602.14349.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, warp@debian.org Received:(qmail 13254 invoked by uid 61); 1 Jun 2002 13:07:12 -0000 Message-Id:<20020601130711.13253.qmail@sources.redhat.com> Date: Sat, 01 Jun 2002 06:16:00 -0000 From: warp@debian.org Reply-To: warp@debian.org To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version:gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c/6893: gcc generates invalid code for x86 subarches. X-SW-Source: 2002-06/txt/msg00001.txt.bz2 List-Id: >Number: 6893 >Category: c >Synopsis: gcc generates invalid code for x86 subarches. >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Sat Jun 01 06:16:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: warp@debian.org >Release: 3.0 and 3.1 >Organization: >Environment: Debian SID, 1GHz Athlon Thunderbird >Description: gcc generates code which does not seem to behave correctly for the source below when using -march=pentium, pentium-mmx, pentium2, athlon, and athlon-tbird. It may also generate bad code for other flags but I have not been able to test such yet. >How-To-Repeat: Compile with 'gcc-3.1 -o bad_gcc bad_gcc.c -Wall -O2 -march=athlon' or the like, use with './bad_gcc 0.5 0.2 0.3 0.5'. The program should covert four floats given on the command line, which should be in the 0-1 range, to bytes in the 0-255 range. Source starts here: #include #include #define min(a,b) ((a) < (b) ? (a) : (b)) float source[4]; float tmp[4]; unsigned char out[4]; extern void inline FtoUB (float *in, char *out, int num) { int i, *icolor; float *fcolor_to; fcolor_to = tmp; // shift float to have 8bit fraction at base of number for (i = 0; i < num; i += 4) { fcolor_to[i ] = in[i ] + 32768.0f; fcolor_to[i + 1] = in[i + 1] + 32768.0f; fcolor_to[i + 2] = in[i + 2] + 32768.0f; fcolor_to[i + 3] = in[i + 3] + 32768.0f; } icolor = (int *) tmp; // then read as integer and kill float bits... for (i = 0; i < num; i += 4) { out[i ] = (char) min(icolor[i ] & 0x7FFFFF, 255); out[i + 1] = (char) min(icolor[i + 1] & 0x7FFFFF, 255); out[i + 2] = (char) min(icolor[i + 2] & 0x7FFFFF, 255); out[i + 3] = (char) min(icolor[i + 3] & 0x7FFFFF, 255); } } int main (int argc, char *argv[]) { source[0] = atof(argv[1]); source[1] = atof(argv[2]); source[2] = atof(argv[3]); source[3] = atof(argv[4]); FtoUB(source, out, 4); printf("in: %f %f %f %f\n", source[0], source[1], source[2], source[3]); printf("out: %d %d %d %d\n", out[0], out[1], out[2], out[3]); exit (0); } >Fix: Work around is to either use gcc 2.95 or to not use -march. >Release-Note: >Audit-Trail: >Unformatted: