If you compile the function
void assign2(float* a, double b) {
volatile float v = -b;
*a = -v;
}
you will see that GCC 4.1.2, e.g., at -O2, produces
fldl 12(%ebp)
fchs
movl 8(%ebp), %eax
fstps -20(%ebp)
flds -20(%ebp)
fstps -4(%ebp)
flds -4(%ebp)
fchs
fstps (%eax)
insted of simply
fldl 12(%ebp)
fchs
fstps -4(%ebp)
flds -4(%ebp)
fchs
fstps (%eax)
--
Summary: Badly optimized negations on x86 with -frounding-math
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bagnara at cs dot unipr dot it
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33675