https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63408
Bug ID: 63408
Summary: GCC emits incorrect FMA instruction
Product: gcc
Version: 4.8.4
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: itay at phobotic dot com
When compiling the following function
float f(float a, int b)
{
return a - (((float)b / 0x7fffffff) * 100);
}
with the following command-line options
arm-none-eabi-gcc -O2 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp
-mcpu=cortex-m4
I get this code for f:
fmsr s14, r1 @ int
flds s15, .L2
vcvt.f32.s32 s14, s14, #31
fmsr s13, r0
vfma.f32 s13, s14, s15
fmrs r0, s13
bx lr
.L3:
.align 2
.L2:
.word 1120403456
The resulting code clearly adds the parenthesized expression to a rather than
subtracting it.
Replacing the minus sign with a plus sign results in the same code.