public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/39501]  New: -O -ffinite-math-only gets min(x,y) optimization wrong for SF on arm-*-gnueabi
@ 2009-03-19 13:31 martinwguy at yahoo dot it
  2009-03-19 15:53 ` [Bug target/39501] " ramana dot r at gmail dot com
                   ` (14 more replies)
  0 siblings, 15 replies; 19+ messages in thread
From: martinwguy at yahoo dot it @ 2009-03-19 13:31 UTC (permalink / raw)
  To: gcc-bugs

The following fragment when compiled -O -ffinite-math-only on arm-linux-gnueabi
should print 0.000000 but with gcc-4.1.2, 4.2.4, 4.3.3 it prints 99999.000000

#include <stdio.h>

#define test_min(x,y)   ((x) >  (y) ? (y) : (x))

int
main (void)
{
        static float data [1];
        float min = 99999.0 ;

        min = test_min (min, data[0]) ;

        printf("min = %f\n", min);

        return min != 0.0 ;
}

This only happens for floats, not doubles. The main difference in the asm is
that without -ffinite-math-only (working) it goes
        mov     r0, r4
        ldr     r1, .L6+4
        bl      __aeabi_fcmplt
        cmp     r0, #0
        ldr     r3, .L6+4
        moveq   r4, r3
        mov     r0, r4
while with -ffinite-math-only (broken) it goes
        ldr     r5, .L5+4
        mov     r0, r4
        mov     r1, r5
        bl      __aeabi_fcmple
        cmp     r0, #0
        movgt   r4, r5
        mov     r0, r4
I guess that should be moveq.

This makes libvorbis fail on arm-linux-gnueabi when using softfloat.
See https://trac.xiph.org/ticket/1526 for a longer code example failing on
min() and max().


-- 
           Summary: -O -ffinite-math-only gets min(x,y) optimization wrong
                    for SF on arm-*-gnueabi
           Product: gcc
           Version: 4.3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: martinwguy at yahoo dot it
GCC target triplet: arm-linux-gnueabi


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39501


^ permalink raw reply	[flat|nested] 19+ messages in thread
[parent not found: <bug-39501-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2014-04-28 14:02 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-19 13:31 [Bug target/39501] New: -O -ffinite-math-only gets min(x,y) optimization wrong for SF on arm-*-gnueabi martinwguy at yahoo dot it
2009-03-19 15:53 ` [Bug target/39501] " ramana dot r at gmail dot com
2009-03-19 16:05 ` ramana dot r at gmail dot com
2009-03-19 16:30 ` martinwguy at yahoo dot it
2009-03-19 16:49 ` ramana dot r at gmail dot com
2009-03-19 16:53 ` rearnsha at gcc dot gnu dot org
2009-03-19 17:02 ` rearnsha at gcc dot gnu dot org
2009-03-19 18:18 ` pinskia at gcc dot gnu dot org
2009-03-29 17:49 ` martinwguy at yahoo dot it
2009-04-04 10:37 ` [Bug target/39501] -O -ffinite-math-only gets min(x,y) optimization wrong for soft-float " rearnsha at gcc dot gnu dot org
2009-04-04 11:23 ` martinwguy at yahoo dot it
2009-04-04 11:50 ` martinwguy at yahoo dot it
2009-04-04 11:53 ` steven at gcc dot gnu dot org
2009-04-04 12:00 ` steven at gcc dot gnu dot org
2009-04-04 12:25 ` rearnsha at gcc dot gnu dot org
2009-05-16 22:25 ` rearnsha at gcc dot gnu dot org
     [not found] <bug-39501-4@http.gcc.gnu.org/bugzilla/>
2010-12-03 11:04 ` ramana at gcc dot gnu.org
2010-12-03 14:46 ` martinwguy at gmail dot com
2014-04-28 14:02 ` 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).