glibc-2.10.1 is not correctly compiled with gcc-4.4.1 for sh4-linux.
I attached preproccessed code.

Reproduce: sh4-linux-gcc -O2 -fPIC -S strtod_l.i

Wrong part is as follows.
.L453:
        mov     #64,r13
        tst     r9,r9           !!
        add     r14,r13
        mov.l   @(4,r13),r0
#APP
! 1306 "strtod_l.c" 1
        mov r11,r5              !! udiv_qrnnd macro
        swap.w r7,r4
        swap.w r5,r6
        jsr @r10                ! call __udiv_qrnnd_16
        shll16 r6
        swap.w r4,r4
        jsr @r10                ! call __udiv_qrnnd_16
        swap.w r1,r8
        or r1,r8
! 0 "" 2
#NO_APP
        bf/s    .L323
        mov.l   r0,@(4,r13)

In this code, "tst r9,r9" is moved to wrong place as if
"t" bit is not clobbered in __udiv_qrnnd_16.

I guessed that missing "t" bit constraint in udiv_qrnnd macro
caused this problem. So I tried following patch, but there was
no effect.

Index: gcc/longlong.h
===================================================================
--- gcc/longlong.h      (revision 150591)
+++ gcc/longlong.h      (working copy)
@@ -982,7 +982,7 @@
 "      or r1,%0"                                                       \
        : "=r" (q), "=&z" (r)                                           \
        : "1" (n1), "r" (n0), "rm" (d), "r" (&__udiv_qrnnd_16)          \
-       : "r1", "r2", "r4", "r5", "r6", "pr");                          \
+       : "r1", "r2", "r4", "r5", "r6", "pr", "t");                     \
   } while (0)

 #define UDIV_TIME 80


-- 
           Summary: [4.4 Regression] SH: miscompilation for sh4-linux
           Product: gcc
           Version: 4.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sugioka at itonet dot co dot jp


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

Reply via email to