public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Roman Zippel <zippel@linux-m68k.org>
To: gcc-gnats@gcc.gnu.org
Subject: c/3095: gcc miscompiles __udivdi3 (libgcc2.c) for linux-m68k
Date: Fri, 08 Jun 2001 16:46:00 -0000	[thread overview]
Message-ID: <E158Vo0-0007ck-00@sodom> (raw)

>Number:         3095
>Category:       c
>Synopsis:       gcc miscompiles __udivdi3 (libgcc2.c) for linux-m68k
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Fri Jun 08 16:46:02 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Roman Zippel
>Release:        3.0 20010606 (prerelease)
>Organization:
>Environment:
System: Linux sodom 2.2.10 #4 Sun Aug 1 14:25:38 CEST 1999 m68k unknown
Architecture: m68k

	
host: m68k-unknown-linux-gnu
build: m68k-unknown-linux-gnu
target: m68k-unknown-linux-gnu
configured with: ../gcc-3.0/configure --verbose --cache-file=../config.cache --prefix=/usr/local/egcs --enable-languages=c,c++
>Description:
The inline assembly in libgcc2.c is miscompiled, e.g.:

(insn/i 29 149 30 (parallel[ 
            (set (reg/v:SI 42)
                (asm_operands:SI ("divu%.l %4,%1:%0") ("=d") 0[ 
                        (reg/v:SI 39)
                        (reg/v:SI 40)
                        (reg/v:SI 37)
                    ] 
                    [ 
                        (asm_input:SI ("0"))
                        (asm_input:SI ("1"))
                        (asm_input:SI ("dmi"))
                    ]  ("../../gcc-3.0/gcc/libgcc2.c") 532))
            (set (reg/v:SI 39)
                (asm_operands:SI ("divu%.l %4,%1:%0") ("=d") 1[ 
                        (reg/v:SI 39)
                        (reg/v:SI 40)
                        (reg/v:SI 37)
                    ] 
                    [ 
                        (asm_input:SI ("0"))
                        (asm_input:SI ("1"))
                        (asm_input:SI ("dmi"))
                    ]  ("../../gcc-3.0/gcc/libgcc2.c") 532))
        ] ) -1 (nil)
    (expr_list:REG_DEAD (reg/v:SI 37)
        (expr_list:REG_DEAD (reg/v:SI 40)
            (expr_list:REG_UNUSED (reg/v:SI 39)
                (nil)))))

becomes after regmove:

(insn/i 29 187 30 (parallel[ 
            (set (reg/v:SI 42)
                (asm_operands:SI ("divu%.l %4,%1:%0") ("=d") 0[ 
                        (reg/v:SI 42)
                        (reg/v:SI 40)
                        (reg/v:SI 37)
                    ] 
                    [ 
                        (asm_input:SI ("0"))
                        (asm_input:SI ("1"))
                        (asm_input:SI ("dmi"))
                    ]  ("../../gcc-3.0/gcc/libgcc2.c") 532))
            (set (reg/v:SI 42)
                (asm_operands:SI ("divu%.l %4,%1:%0") ("=d") 1[ 
                        (reg/v:SI 42)
                        (reg/v:SI 40)
                        (reg/v:SI 37)
                    ] 
                    [ 
                        (asm_input:SI ("0"))
                        (asm_input:SI ("1"))
                        (asm_input:SI ("dmi"))
                    ]  ("../../gcc-3.0/gcc/libgcc2.c") 532))
        ] ) -1 (nil)
    (expr_list:REG_DEAD (reg/v:SI 37)
        (expr_list:REG_DEAD (reg/v:SI 40)
            (nil))))

Register 39 is replaced, although it's still used as input parameter.
In the end the result is put into the wrong register.

>How-To-Repeat:
Configure for linux-m68k and (cross) compile.
Note that the fixes from bootstrap/3090 and c/3092 are needed to get
at least a cross compiler.
>Fix:
Index: gcc/regmove.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/regmove.c,v
retrieving revision 1.96.2.6
diff -u -r1.96.2.6 regmove.c
--- regmove.c	2001/05/14 16:31:46	1.96.2.6
+++ regmove.c	2001/06/08 19:57:56
@@ -1355,7 +1355,8 @@
 		  continue;
 		}
 
-	      if (! (src_note = find_reg_note (insn, REG_DEAD, src)))
+	      if (! (src_note = find_reg_note (insn, REG_DEAD, src)) &&
+		  ! (src_note = find_reg_note (insn, REG_UNUSED, src)))
 		{
 		  if (!copy_src)
 		    {
>Release-Note:
>Audit-Trail:
>Unformatted:


                 reply	other threads:[~2001-06-08 16:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E158Vo0-0007ck-00@sodom \
    --to=zippel@linux-m68k.org \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).