public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: mi+gcc@aldan.algebra.com
To: gcc-gnats@gcc.gnu.org
Cc: das@FreeBSD.org
Subject: optimization/10774: Problem with ``-march=pentium4 -O''
Date: Wed, 14 May 2003 00:26:00 -0000	[thread overview]
Message-ID: <20030514002143.5611.qmail@sources.redhat.com> (raw)


>Number:         10774
>Category:       optimization
>Synopsis:       Problem with ``-march=pentium4 -O''
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Wed May 14 00:26:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Mikhail Teterin
>Release:        gcc version 3.2.2
>Organization:
>Environment:
Reproduceable with:
	gcc version 3.2.2 [FreeBSD] 20030205 (release)
	gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)
>Description:
The attached file (you can remove the ``#include <stdio.h>'' line if you
insist) gets miscompiled with ``-march=pentium4 -O''. Removing the -O
or specifying another architecture (such as pentium3) fixes the problem.

The expected result is 0.5. But an optimized for pentium4 version
produces 5.29463e-315 (same value on both Linux and FreeBSD).
According to the debugger, the 22-nd line is skipped in the P4 case.

See also the FreeBSD problem reports:
	http://www.FreeBSD.org/cgi/query-pr.cgi?pr=bin/43299
	http://www.FreeBSD.org/cgi/query-pr.cgi?pr=i386/51210

	

>How-To-Repeat:
% cc -O1 -march=pentium4 simple_pow.c -Wall && ./a.out
7.000000 ^ 2.100000
7.000000 ^ 2.100000
ax is 5.29463e-315
result is 5.29463e-315
% cc -O1 -march=pentium3 simple_pow.c -Wall && ./a.out
7.000000 ^ 2.100000
7.000000 ^ 2.100000
ax is 0.5
result is 0.5
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/x-csrc; name="simple_pow.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="simple_pow.c"

I2luY2x1ZGUgPHN0ZGlvLmg+Cgpkb3VibGUgZmFicyhkb3VibGUpOwp0eXBlZGVmIHVuaW9uIHsK
CWRvdWJsZSB2YWx1ZTsKCXN0cnVjdCB7CgkJdW5zaWduZWQgaW50IGxzdzsKCQl1bnNpZ25lZCBp
bnQgbXN3OwoJfSBwYXJ0czsKfSBpZWVlX2RvdWJsZV9zaGFwZV90eXBlOwoKZG91YmxlCmJ1Zyhk
b3VibGUgeCwgZG91YmxlIHksIGludCBpeCkKewoJZG91YmxlIGF4OwoJaWVlZV9kb3VibGVfc2hh
cGVfdHlwZSBzaF91OwoKCXByaW50ZigiJWYgXiAlZlxuIiwgeCwgeSk7CglheCA9IGZhYnMoeCk7
CglwcmludGYoIiVmIF4gJWZcbiIsIGF4LCB5KTsKCglzaF91LnZhbHVlID0gYXg7CglzaF91LnBh
cnRzLm1zdyA9IGl4OwoJYXggPSBzaF91LnZhbHVlOwoKCXByaW50ZigiYXggaXMgJWdcbiIsIGF4
KTsKCglyZXR1cm4gYXg7Cn0KCmludCBtYWluKCkgewoJcHJpbnRmKCJyZXN1bHQgaXMgJWdcbiIs
IGJ1Zyg3LjAsIDIuMSwgMTA3MTY0NDY3MikpOwoJcmV0dXJuIDA7Cn0K


             reply	other threads:[~2003-05-14  0:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-14  0:26 mi+gcc [this message]
2003-05-14 18:06 Dara Hazeghi
2003-05-15  1:06 Mikhail Teterin
2003-05-15  3:06 Dara Hazeghi
2003-05-15 13:55 bangerth
2003-05-15 14:26 Mikhail Teterin

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=20030514002143.5611.qmail@sources.redhat.com \
    --to=mi+gcc@aldan.algebra.com \
    --cc=das@FreeBSD.org \
    --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).