public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: jkain@nvidia.com
To: gcc-gnats@gcc.gnu.org
Subject: optimization/10667: Optimizer confused when operating on floats as ints.
Date: Wed, 07 May 2003 16:36:00 -0000	[thread overview]
Message-ID: <20030507163232.30957.qmail@sources.redhat.com> (raw)


>Number:         10667
>Category:       optimization
>Synopsis:       Optimizer confused when operating on floats as ints.
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed May 07 16:36:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Joseph Kain
>Release:        gcc version 3.2.3
>Organization:
>Environment:
Linux 2.4, i686.
>Description:
The program below was built as:
  gcc -v -save-temps -O3 -c -o bug.o bug.c

$ gcc -v
Reading specs from /home/joseph/t/gcc/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/specs
Configured with: ../gcc-3.2.3/configure --prefix=/home/joseph/t/gcc
Thread model: posix
gcc version 3.2.3


If I examine the assembly output I find that the compiler has completely removed the multiply.  Code for the compare is generated but the compare result may be wrong since f.x was never computed.
>How-To-Repeat:
# 1 "bug.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "bug.c"


struct vector {
    float x, y, z, w;
};

int func (float f1, float f2) {
    struct vector f;

    f.x = f1 * f2;

    if ((*(int *) &(f.x)) > 0) {
        return 1;
    }

    return 0;
}
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


             reply	other threads:[~2003-05-07 16:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-07 16:36 jkain [this message]
2003-05-07 17:01 ebotcazou

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=20030507163232.30957.qmail@sources.redhat.com \
    --to=jkain@nvidia.com \
    --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).