public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/52258] New: __builtin_isgreaterequal is sometimes signaling on ARM
@ 2012-02-15 10:24 aurelien at aurel32 dot net
  2012-02-19 11:31 ` [Bug target/52258] " mikpe at it dot uu.se
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: aurelien at aurel32 dot net @ 2012-02-15 10:24 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52258
           Summary: __builtin_isgreaterequal is sometimes signaling on ARM
    Classification: Unclassified
           Product: gcc
           Version: 4.6.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: aurelien@aurel32.net
              Host: armv7l-unknown-linux-gnueabihf
            Target: armv7l-unknown-linux-gnueabihf
             Build: armv7l-unknown-linux-gnueabihf


__builtin_isgreaterequal is supposed to be non-signaling in case a qNaN is
provided in input. It works when the function is alone, but when combined with
another test, it sometimes triggered an invalid FP exception at -O1 and above
optimization levels.

For example:
int sel_fmax (double x, double y)
{
  return __builtin_isgreaterequal(x, y) || isnan(y);
}


At -O0, the corresponding assembly code is:
00000000 <sel_fmax>:
   0:   b580            push    {r7, lr}
   2:   b084            sub     sp, #16
   4:   af00            add     r7, sp, #0
   6:   ed87 0b02       vstr    d0, [r7, #8]
   a:   ed87 1b00       vstr    d1, [r7]
   e:   ed97 6b02       vldr    d6, [r7, #8]
  12:   ed97 7b00       vldr    d7, [r7]
  16:   eeb4 6b47       vcmp.f64        d6, d7
  1a:   eef1 fa10       vmrs    APSR_nzcv, fpscr
  1e:   bfac            ite     ge
  20:   2300            movge   r3, #0
  22:   2301            movlt   r3, #1
  24:   b2db            uxtb    r3, r3
  26:   f083 0301       eor.w   r3, r3, #1
  2a:   b2db            uxtb    r3, r3
  2c:   2b00            cmp     r3, #0
  2e:   d106            bne.n   3e <selfmax+0x3e>
  30:   ed97 0b00       vldr    d0, [r7]
  34:   f7ff fffe       bl      0 <__isnan>
                        34: R_ARM_THM_CALL      __isnan
  38:   4603            mov     r3, r0
  3a:   2b00            cmp     r3, #0
  3c:   d002            beq.n   44 <selfmax+0x44>
  3e:   f04f 0301       mov.w   r3, #1
  42:   e001            b.n     48 <selfmax+0x48>
  44:   f04f 0300       mov.w   r3, #0
  48:   4618            mov     r0, r3
  4a:   f107 0710       add.w   r7, r7, #16
  4e:   46bd            mov     sp, r7
  50:   bd80            pop     {r7, pc}
  52:   bf00            nop


At -O1, the corresponding assembly code is:
00000000 <sel_fmax>:
   0:   b508            push    {r3, lr}
   2:   eeb4 0bc1       vcmpe.f64       d0, d1
   6:   eef1 fa10       vmrs    APSR_nzcv, fpscr
   a:   da07            bge.n   1c <selfmax+0x1c>
   c:   eeb0 0b41       vmov.f64        d0, d1
  10:   f7ff fffe       bl      0 <__isnan>
                        10: R_ARM_THM_CALL      __isnan
  14:   3000            adds    r0, #0
  16:   bf18            it      ne
  18:   2001            movne   r0, #1
  1a:   bd08            pop     {r3, pc}
  1c:   f04f 0001       mov.w   r0, #1
  20:   bd08            pop     {r3, pc}
  22:   bf00            nop


Note how the vcmp.f64 is changed into a vcmpe.f64, triggering an invalid
exception. This means that a lot of the FP functions in the GNU libc trigger an
invalid exception where they should not, therefore rendering FP exceptions
unusable on ARM.


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

* [Bug target/52258] __builtin_isgreaterequal is sometimes signaling on ARM
  2012-02-15 10:24 [Bug target/52258] New: __builtin_isgreaterequal is sometimes signaling on ARM aurelien at aurel32 dot net
@ 2012-02-19 11:31 ` mikpe at it dot uu.se
  2012-02-19 12:23 ` aurelien at aurel32 dot net
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: mikpe at it dot uu.se @ 2012-02-19 11:31 UTC (permalink / raw)
  To: gcc-bugs

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

Mikael Pettersson <mikpe at it dot uu.se> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikpe at it dot uu.se

--- Comment #1 from Mikael Pettersson <mikpe at it dot uu.se> 2012-02-19 11:23:54 UTC ---
Can you provide a standalone runtime test case that fails (with a SIGFPE I
assume) when the bug is triggered?


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

* [Bug target/52258] __builtin_isgreaterequal is sometimes signaling on ARM
  2012-02-15 10:24 [Bug target/52258] New: __builtin_isgreaterequal is sometimes signaling on ARM aurelien at aurel32 dot net
  2012-02-19 11:31 ` [Bug target/52258] " mikpe at it dot uu.se
@ 2012-02-19 12:23 ` aurelien at aurel32 dot net
  2012-02-19 23:49 ` mikpe at it dot uu.se
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: aurelien at aurel32 dot net @ 2012-02-19 12:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Aurelien Jarno <aurelien at aurel32 dot net> 2012-02-19 11:30:36 UTC ---
Created attachment 26700
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26700
Testcase


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

* [Bug target/52258] __builtin_isgreaterequal is sometimes signaling on ARM
  2012-02-15 10:24 [Bug target/52258] New: __builtin_isgreaterequal is sometimes signaling on ARM aurelien at aurel32 dot net
  2012-02-19 11:31 ` [Bug target/52258] " mikpe at it dot uu.se
  2012-02-19 12:23 ` aurelien at aurel32 dot net
@ 2012-02-19 23:49 ` mikpe at it dot uu.se
  2012-02-23  2:24 ` ramana at gcc dot gnu.org
  2021-07-19 18:48 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: mikpe at it dot uu.se @ 2012-02-19 23:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Mikael Pettersson <mikpe at it dot uu.se> 2012-02-19 23:32:52 UTC ---
On my Tegra2 machine the testcase does report that FE_INVALID got set when
compiled at -O1 with gcc-4.6 and 4.5, but not when compiled at -O0.


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

* [Bug target/52258] __builtin_isgreaterequal is sometimes signaling on ARM
  2012-02-15 10:24 [Bug target/52258] New: __builtin_isgreaterequal is sometimes signaling on ARM aurelien at aurel32 dot net
                   ` (2 preceding siblings ...)
  2012-02-19 23:49 ` mikpe at it dot uu.se
@ 2012-02-23  2:24 ` ramana at gcc dot gnu.org
  2021-07-19 18:48 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: ramana at gcc dot gnu.org @ 2012-02-23  2:24 UTC (permalink / raw)
  To: gcc-bugs

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

Ramana Radhakrishnan <ramana at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-02-23
                 CC|                            |ramana at gcc dot gnu.org
      Known to work|                            |4.7.0
     Ever Confirmed|0                           |1
      Known to fail|                            |4.6.3

--- Comment #4 from Ramana Radhakrishnan <ramana at gcc dot gnu.org> 2012-02-23 02:22:28 UTC ---
Fails for anything earlier than trunk strangely enough while 4.6 goes wrong. 

Trunk at O2 appears to generate :

00000000 <main>:
   0:    ed9f 7b13     vldr    d7, [pc, #76]    ; 50 <main+0x50>
   4:    ee87 7b07     vdiv.f64    d7, d7, d7
   8:    b510          push    {r4, lr}
   a:    201f          movs    r0, #31
   c:    b082          sub    sp, #8
   e:    ed8d 7b00     vstr    d7, [sp]
  12:    f7ff fffe     bl    0 <feclearexcept>
  16:    ed9d 7b00     vldr    d7, [sp]
  1a:    eeb5 7b40     vcmp.f64    d7, #0.0
  1e:    eef1 fa10     vmrs    APSR_nzcv, fpscr
  22:    da10          bge.n    46 <main+0x46>
  24:    e9dd 0100     ldrd    r0, r1, [sp]
  28:    f7ff fffe     bl    0 <__isnan>
  2c:    1c04          adds    r4, r0, #0
  2e:    bf18          it    ne
  30:    2401          movne    r4, #1
  32:    2001          movs    r0, #1
  34:    f7ff fffe     bl    0 <fetestexcept>
  38:    b110          cbz    r0, 40 <main+0x40>
  3a:    4807          ldr    r0, [pc, #28]    ; (58 <main+0x58>)
  3c:    f7ff fffe     bl    0 <puts>
  40:    4620          mov    r0, r4
  42:    b002          add    sp, #8
  44:    bd10          pop    {r4, pc}
  46:    2401          movs    r4, #1
  48:    e7f3          b.n    32 <main+0x32>
  4a:    bf00          nop
  4c:    f3af 8000     nop.w
    ...


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

* [Bug target/52258] __builtin_isgreaterequal is sometimes signaling on ARM
  2012-02-15 10:24 [Bug target/52258] New: __builtin_isgreaterequal is sometimes signaling on ARM aurelien at aurel32 dot net
                   ` (3 preceding siblings ...)
  2012-02-23  2:24 ` ramana at gcc dot gnu.org
@ 2021-07-19 18:48 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-19 18:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52258

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I think this was fixed in GCC 10 with r10-6245 and maybe a few others.

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

end of thread, other threads:[~2021-07-19 18:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-15 10:24 [Bug target/52258] New: __builtin_isgreaterequal is sometimes signaling on ARM aurelien at aurel32 dot net
2012-02-19 11:31 ` [Bug target/52258] " mikpe at it dot uu.se
2012-02-19 12:23 ` aurelien at aurel32 dot net
2012-02-19 23:49 ` mikpe at it dot uu.se
2012-02-23  2:24 ` ramana at gcc dot gnu.org
2021-07-19 18:48 ` pinskia 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).