public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/62098] New: incorrect code generated by arm  gcc
@ 2014-08-11 20:56 carrot at google dot com
  2014-08-12 12:19 ` [Bug target/62098] [4.9 regression] " ramana at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: carrot at google dot com @ 2014-08-11 20:56 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-08-20 11:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-11 20:56 [Bug target/62098] New: incorrect code generated by arm gcc carrot at google dot com
2014-08-12 12:19 ` [Bug target/62098] [4.9 regression] " ramana at gcc dot gnu.org
2014-08-12 12:37 ` [Bug target/62098] [4.9/4.10 " ramana at gcc dot gnu.org
2014-08-12 13:03 ` ramana at gcc dot gnu.org
2014-08-12 14:32 ` ramana at gcc dot gnu.org
2014-08-20 11:31 ` [Bug target/62098] [4.9/5 " ramana at gcc dot gnu.org
2014-08-20 11:53 ` ramana at gcc dot gnu.org

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).