From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8257 invoked by alias); 14 May 2003 00:26:01 -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 8228 invoked by uid 71); 14 May 2003 00:26:00 -0000 Resent-Date: 14 May 2003 00:26:00 -0000 Resent-Message-ID: <20030514002600.8227.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, das@FreeBSD.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, mi+gcc@aldan.algebra.com Received: (qmail 5612 invoked by uid 48); 14 May 2003 00:21:43 -0000 Message-Id: <20030514002143.5611.qmail@sources.redhat.com> Date: Wed, 14 May 2003 00:26:00 -0000 From: mi+gcc@aldan.algebra.com Reply-To: mi+gcc@aldan.algebra.com To: gcc-gnats@gcc.gnu.org Cc: das@FreeBSD.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) X-GNATS-Notify: das@FreeBSD.org Subject: optimization/10774: Problem with ``-march=pentium4 -O'' X-SW-Source: 2003-05/txt/msg01525.txt.bz2 List-Id: >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 '' 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