From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17078 invoked by alias); 9 Dec 2002 17:56:07 -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 16997 invoked by uid 71); 9 Dec 2002 17:56:04 -0000 Resent-Date: 9 Dec 2002 17:56:04 -0000 Resent-Message-ID: <20021209175604.16996.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, Luca "Kronos" Tettamanti Received: (qmail 11799 invoked from network); 9 Dec 2002 17:53:09 -0000 Received: from unknown (HELO mail.tiscali.it) (195.130.225.147) by sources.redhat.com with SMTP; 9 Dec 2002 17:53:09 -0000 Received: from dreamland.darkstar.lan (217.133.181.62) by mail.tiscali.it (6.5.032) id 3DEF07E7001E93A1 for gcc-gnats@gcc.gnu.org; Mon, 9 Dec 2002 18:53:08 +0100 Received: by dreamland.darkstar.lan (Postfix, from userid 1000) id 1DFEF41B4; Mon, 9 Dec 2002 18:53:16 +0100 (CET) Message-Id: <20021209175316.1DFEF41B4@dreamland.darkstar.lan> Date: Mon, 09 Dec 2002 09:56:00 -0000 From: Luca "Kronos" Tettamanti To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: 3.113 Subject: optimization/8878: miscompilation with -O and SSE X-SW-Source: 2002-12/txt/msg00477.txt.bz2 List-Id: >Number: 8878 >Category: optimization >Synopsis: miscompilation with -O and SSE >Confidential: no >Severity: serious >Priority: low >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Mon Dec 09 09:56:04 PST 2002 >Closed-Date: >Last-Modified: >Originator: >Release: 3.2.1 >Organization: >Environment: System: Linux dreamland 2.4.20-rc3-xfs-acpi #9 Wed Nov 27 18:01:32 CET 2002 i686 unknown Architecture: i686 host: i686-pc-linux-gnu build: i686-pc-linux-gnu target: i686-pc-linux-gnu configured with: ../gcc/configure --prefix=/usr --enable-shared --with-slibdir=/lib --with-gnu-as --with-gnu-ld --enable-threads --enable-languages=c,c++ >Description: gcc produce wrong assembly when using vector instructions through built-in functions and -O. I was benchmarking pure FPU vs. SSE, so the program is a loop that multiply and add 2 vector. >How-To-Repeat: #include int main(void) { typedef int v4sf __attribute__ ((mode(V4SF))); v4sf a = {2.0, 2.0, 2.0, 2.0}; v4sf b = {1.0, 2.0, 3.0, 4.0}; v4sf c = {0.0, 0.0, 0.0, 0.0}; v4sf d; int i; for(i = 0; i < 1000000; i++) { d = __builtin_ia32_mulps(a, b); c = __builtin_ia32_addps(c, d); } for (i = 0; i < 4; i++) printf("%f ", *(((float *)(&c)) + i)); printf("\n"); return 0; } Compiled with: gcc -Wall -ofloat-sse -march=athlon-xp float-sse.c it gives me the following (correct) output: kronos:~/c$ float-sse 2000000.000000 4000000.000000 6000000.000000 8000000.000000 Compiled with: gcc -O -Wall -ofloat-sse -march=athlon-xp float-sse.c it gives a wrong output: kronos:~/c$ float-sse 8000000.000000 0.000000 0.000000 0.000000 Assembly output available if needed. >Fix: Don't know. >Release-Note: >Audit-Trail: >Unformatted: