public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: gcc-patches@sourceware.org
Subject: [commit, spu] Fix (latent) ICE in spu_expand_mov
Date: Wed, 22 Dec 2010 15:34:00 -0000	[thread overview]
Message-ID: <201012221511.oBMFBBh9015886@d06av02.portsmouth.uk.ibm.com> (raw)

Hello,

in a compiler build with Tom de Vries' new sign/zero extension elimination
pass added (http://gcc.gnu.org/ml/gcc-patches/2010-10/msg01529.html), I'm
seeing frequent internal compiler errors on the SPU.

The reason is that this new pass frequently generates move instructions
whose destination is a sub-word lowpart subreg.  Now the problem on the
SPU is some of those subregs are not directly valid (e.g. a SImode lowpart
of a DImode value cannot be implemented by just reinterpreting register
contents, but requires an actual shift due to the way values are laid out
in the 16-bit SPU registers).  The SPU move expander attempts to rewrite
moves to eliminate such invalid subregs.  However, it expects them to
occur only on the *source* of a move, never the destination.

Interestingly enough, this apparently never happens in a compiler without
the extension elimination pass.  On the other hand, such move instructions
seem to be valid RTL as far as I can see from the docs, so the SPU back-
end really ought to support them ...

The following patch fixes this problem by having the move expander
simply remove the subreg and perform the move in the inner mode.
This fixes the ICEs with the extension elimination pass.

Tested with no regressions on spu-elf.
Committed to mainline.

Bye,
Ulrich


ChangeLog:

	* config/spu/spu.md ("mov<mode>"): Use nonimmediate_operand
	predicate for destination operand.
	* config/spu/spu.c (spu_expand_mov): If move destination is an
	invalid subreg, perform move in the subreg's inner mode instead.

diff -urp gcc/config/spu.orig/spu.c gcc/config/spu/spu.c
--- gcc/config/spu.orig/spu.c	2010-12-10 16:51:16.000000000 +0100
+++ gcc/config/spu/spu.c	2010-12-21 16:49:02.000000000 +0100
@@ -4572,7 +4572,13 @@ int
 spu_expand_mov (rtx * ops, enum machine_mode mode)
 {
   if (GET_CODE (ops[0]) == SUBREG && !valid_subreg (ops[0]))
-    abort ();
+    {
+      /* Perform the move in the destination SUBREG's inner mode.  */
+      ops[0] = SUBREG_REG (ops[0]);
+      mode = GET_MODE (ops[0]);
+      ops[1] = gen_lowpart_common (mode, ops[1]);
+      gcc_assert (ops[1]);
+    }
 
   if (GET_CODE (ops[1]) == SUBREG && !valid_subreg (ops[1]))
     {
diff -urp gcc/config/spu.orig/spu.md gcc/config/spu/spu.md
--- gcc/config/spu.orig/spu.md	2010-12-10 16:51:16.000000000 +0100
+++ gcc/config/spu/spu.md	2010-12-21 16:57:27.000000000 +0100
@@ -269,8 +269,8 @@
 ;; mov
 
 (define_expand "mov<mode>"
-  [(set (match_operand:ALL 0 "spu_nonimm_operand" "=r,r,r,m")
-	(match_operand:ALL 1 "general_operand" "r,i,m,r"))]
+  [(set (match_operand:ALL 0 "nonimmediate_operand" "")
+	(match_operand:ALL 1 "general_operand" ""))]
   ""
   {
     if (spu_expand_mov(operands, <MODE>mode))
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com

                 reply	other threads:[~2010-12-22 15:11 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=201012221511.oBMFBBh9015886@d06av02.portsmouth.uk.ibm.com \
    --to=uweigand@de.ibm.com \
    --cc=gcc-patches@sourceware.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).