[Bug target/62098] New: incorrect code generated by arm gcc
carrot at google dot com
gcc-bugzilla@gcc.gnu.org
Mon Aug 11 20:56:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62098
Bug ID: 62098
Summary: incorrect code generated by arm gcc
Product: gcc
Version: 4.10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: carrot at google dot com
Target: arm-unknown-linux-gnueabi
Compile following source code with options -march=armv7-a -mfpu=vfpv3
-mfloat-abi=softfp -O2 -std=gnu++11
#include <limits>
#include <cmath>
const int kFixedPointDenominator = 64;
float ceilToFloat(int m_value) {
float floatValue = static_cast<float>(m_value) / kFixedPointDenominator;
if (static_cast<int>(floatValue * kFixedPointDenominator) == m_value)
return floatValue;
if (floatValue > 0)
return nextafterf(floatValue, std::numeric_limits<float>::max());
return nextafterf(floatValue, std::numeric_limits<float>::min());
}
trunk gcc generates:
fmsr s15, r0 @ int
vcvt.f32.s32 s15, s15, #6 // A
vcvt.s32.f32 s15, s15, #6 // B
vmov r3, s15
cmp r3, r0
beq .L2
fcmpezs s15
fmstat
ble .L6
movw r1, #65535
fmrs r0, s15
movt r1, 32639
b nextafterf
.L6:
mov r1, #8388608
fmrs r0, s15
b nextafterf
.L2:
fmrs r0, s15 // C
bx lr
Instruction C returns the result of instruction B, but the expected return
value is the result of instruction A.
4.9 branch generates the same wrong codes, but 4.8 is correct.
More information about the Gcc-bugs
mailing list