optimization/10667: Optimizer confused when operating on floats as ints.
jkain@nvidia.com
jkain@nvidia.com
Wed May 7 16:51:00 GMT 2003
>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:
More information about the Gcc-bugs
mailing list