public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Luca "Kronos" Tettamanti <kronoz@tiscali.it>
To: gcc-gnats@gcc.gnu.org
Subject: optimization/8878: miscompilation with -O and SSE
Date: Mon, 09 Dec 2002 09:56:00 -0000	[thread overview]
Message-ID: <20021209175316.1DFEF41B4@dreamland.darkstar.lan> (raw)


>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 <stdio.h>

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:


             reply	other threads:[~2002-12-09 17:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-09  9:56 Luca Kronos Tettamanti [this message]
2002-12-11  6:08 reichelt
2003-04-02 20:16 Janis Johnson
2003-04-02 20:16 Volker Reichelt
2003-04-03 19:36 Janis Johnson
2003-05-02 16:34 reichelt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20021209175316.1DFEF41B4@dreamland.darkstar.lan \
    --to=kronoz@tiscali.it \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).