This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH/RFC] SH: Many ICEs on complex numbers


Hi,

Currently there are many regressions on mainline and the libgfortran
fails to build for sh4-unknown-linux-gnu.  It looks they are ICEs
related with the handling of complex numbers.  The typical failure is:

/gcc/gcc/testsuite/gcc.c-torture/compile/981223-1.c: In function ‘func’:
/gcc/gcc/testsuite/gcc.c-torture/compile/981223-1.c:17: error: insn does not satisfy its constraints:
(insn 58 72 80 (set (reg:DI 0 r0)
        (reg:DI 68 fr4 [ x ])) 143 {*movdi_i} (nil)
    (nil))
/gcc/gcc/testsuite/gcc.c-torture/compile/981223-1.c:17: internal compiler error: in final_scan_insn, at final.c:2432

Looking .lreg and .greg dumps, it seems that emit_move_complex tries
to rewrite the move from the subreg of a SCmode register to the memory

  (insn 3 6 4 1 (set (mem/i:DI (reg/f:SI 14 r14) [0 x+0 S8 A32])
          (subreg:DI (reg:SC 68 fr4 [ x ]) 0)) 143 {*movdi_i} (nil)
      (expr_list:REG_DEAD (reg:SC 68 fr4 [ x ])
          (nil)))

with moves via integer

  (insn 60 6 3 1 (set (reg:DI 0 r0)
          (reg:DI 68 fr4 [ x ])) 143 {*movdi_i} (nil)
      (nil))
 
  (insn 3 60 4 1 (set (mem/i:DI (reg/f:SI 14 r14) [0 x+0 S8 A32])
          (reg:DI 0 r0)) 143 {*movdi_i} (nil)
      (nil))

Unfortunately SH-4 doesn't have the move instructions from the float
register to the integer register and the above insn #60 causes an ICE.
The patch below tries to fix that.
Bootstrapped on i686-pc-linux-gnu without regressions and the failures
of this type on x86 cross sh4-unknown-linux-gnu went away with it.

Regards,
	kaz
--
2004-12-08  Kaz Kojima  <kkojima@gcc.gnu.org>

	* expr.c (emit_move_via_alt_mode): Return NULL_RTX if the GEN_FCN
	for the alt_mode move returns null.

	* config/sh/sh.md (movdi): Make it fail if it's a move between
	memory and subreg of SCmode reg.

diff -uprN ORIG/gcc/gcc/expr.c LOCAL/gcc/gcc/expr.c
--- ORIG/gcc/gcc/expr.c	2004-12-07 09:14:32.000000000 +0900
+++ LOCAL/gcc/gcc/expr.c	2004-12-08 17:53:58.000000000 +0900
@@ -2661,6 +2661,8 @@ static rtx
 emit_move_via_alt_mode (enum machine_mode alt_mode, enum machine_mode mode,
 			enum insn_code code, rtx x, rtx y)
 {
+  rtx pat;
+
   /* Get X and Y in ALT_MODE.  We can't use gen_lowpart here because it
      may call change_address which is not appropriate if we were
      called when a reload was in progress.  We don't have to worry
@@ -2692,7 +2694,14 @@ emit_move_via_alt_mode (enum machine_mod
       y = simplify_gen_subreg (alt_mode, y, mode, 0);
     }
 
-  return emit_insn (GEN_FCN (code) (x, y));
+  /* Give a chance to the backend not to move via alt mode.  For example,
+     SH-4 doesn't have the move instrunction between the float regsiter
+     and the integer register.  */
+  pat = GEN_FCN (code) (x, y);
+  if (pat)
+    return emit_insn (pat);
+
+  return NULL_RTX;
 }
 
 /* A subroutine of emit_move_insn_1.  Generate a move from Y into X using
diff -uprN ORIG/gcc/gcc/config/sh/sh.md LOCAL/gcc/gcc/config/sh/sh.md
--- ORIG/gcc/gcc/config/sh/sh.md	2004-12-04 22:06:43.000000000 +0900
+++ LOCAL/gcc/gcc/config/sh/sh.md	2004-12-08 14:40:49.000000000 +0900
@@ -4117,7 +4117,19 @@
   [(set (match_operand:DI 0 "general_movdst_operand" "")
 	(match_operand:DI 1 "general_movsrc_operand" ""))]
   ""
-  "{ if (prepare_move_operands (operands, DImode)) DONE; }")
+  "
+{
+  if (TARGET_SH4
+      && ((MEM_P (operands[1])
+	   && GET_CODE (operands[0]) == SUBREG
+	   && GET_MODE (SUBREG_REG (operands[0])) == SCmode)
+	  || (MEM_P (operands[0])
+	      && GET_CODE (operands[1]) == SUBREG
+	      && GET_MODE (SUBREG_REG (operands[1])) == SCmode)))
+    FAIL;
+
+  if (prepare_move_operands (operands, DImode)) DONE;
+}")
 
 (define_insn "movdf_media"
   [(set (match_operand:DF 0 "general_movdst_operand" "=f,f,r,r,r,f,m,r,m")


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]