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]: Fix target/14457: [3.4/3.5? Regression] ICE with simplec++ source


Hi!

This patch fixes the regression 14457.  It was caused by a (MEM:HI (MEM:HI reg))
operand that must be split in two part to access the low and high byte.  Such split
is not possible as there is no (MEM:HI (PLUS:HI (MEM:HI reg) (const_int 1))).

Committed on 3_4 and mainline.

Stephane


2004-06-06 Stephane Carrez <stcarrez@nerim.fr>


	PR target/14457
	* config/m68hc11/m68hc11.c (splitable_operand): New predicate.
	* config/m68hc11/m68hc11-protos.h (splitable_operand): Declare.
	* config/m68hc11/m68hc11.h (PREDICATE_CODES): Register it.
	(inhibit_libc): Must define.
	* config/m68hc11/m68hc11.md ("movhi_const0"): Use splitable_operand.
	("*andhi3_gen", "iorhi3", "*iorhi3_gen"): Likewise.
	("xorhi3"): Likewise.

Index: config/m68hc11/m68hc11.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/m68hc11/m68hc11.c,v
retrieving revision 1.91.6.5
diff -u -p -r1.91.6.5 m68hc11.c
--- config/m68hc11/m68hc11.c	7 Mar 2004 20:58:32 -0000	1.91.6.5
+++ config/m68hc11/m68hc11.c	6 Jun 2004 13:46:30 -0000
@@ -1004,6 +1004,24 @@ non_push_operand (rtx operand, enum mach
 }
 
 int
+splitable_operand (rtx operand, enum machine_mode mode)
+{
+  if (general_operand (operand, mode) == 0)
+    return 0;
+
+  if (push_operand (operand, mode) == 1)
+    return 0;
+
+  /* Reject a (MEM (MEM X)) because the patterns that use non_push_operand
+     need to split such addresses to access the low and high part but it
+     is not possible to express a valid address for the low part.  */
+  if (mode != QImode && GET_CODE (operand) == MEM
+      && GET_CODE (XEXP (operand, 0)) == MEM)
+    return 0;
+  return 1;
+}
+
+int
 reg_or_some_mem_operand (rtx operand, enum machine_mode mode)
 {
   if (GET_CODE (operand) == MEM)
Index: config/m68hc11/m68hc11-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/m68hc11/m68hc11-protos.h,v
retrieving revision 1.30
diff -u -p -r1.30 m68hc11-protos.h
--- config/m68hc11/m68hc11-protos.h	27 Oct 2003 12:26:19 -0000	1.30
+++ config/m68hc11/m68hc11-protos.h	6 Jun 2004 13:46:30 -0000
@@ -1,5 +1,5 @@
 /* Prototypes for exported functions defined in m68hc11.c
-   Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
    Contributed by Stephane Carrez (stcarrez@nerim.fr)
 
 This file is part of GCC.
@@ -104,6 +104,7 @@ extern int memory_reload_operand (rtx, e
 extern int stack_register_operand (rtx, enum machine_mode);
 extern int d_register_operand (rtx, enum machine_mode);
 extern int hard_addr_reg_operand (rtx, enum machine_mode);
+extern int splitable_operand (rtx, enum machine_mode);
 extern int arith_src_operand (rtx, enum machine_mode);
 extern int m68hc11_logical_operator (rtx, enum machine_mode);
 extern int m68hc11_arith_operator (rtx, enum machine_mode);
Index: config/m68hc11/m68hc11.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/m68hc11/m68hc11.h,v
retrieving revision 1.81.4.1
diff -u -p -r1.81.4.1 m68hc11.h
--- config/m68hc11/m68hc11.h	9 Mar 2004 03:00:03 -0000	1.81.4.1
+++ config/m68hc11/m68hc11.h	6 Jun 2004 13:46:32 -0000
@@ -1,6 +1,7 @@
 /* Definitions of target machine for GNU compiler.
    Motorola 68HC11 and 68HC12.
-   Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
+   Free Software Foundation, Inc.
    Contributed by Stephane Carrez (stcarrez@nerim.fr)
 
 This file is part of GCC.
@@ -92,7 +93,9 @@ Note:
   while (0)
 
 /* As an embedded target, we have no libc.  */
-#define inhibit_libc
+#ifndef inhibit_libc
+#  define inhibit_libc
+#endif
 
 /* Forward type declaration for prototypes definitions.
    rtx_ptr is equivalent to rtx. Can't use the same name.  */
@@ -879,7 +882,9 @@ extern enum reg_class m68hc11_tmp_regs_c
 		 && VALUE == CONST0_RTX (GET_MODE (VALUE))) : 0) 
 
 /* 'U' represents certain kind of memory indexed operand for 68HC12.
-   and any memory operand for 68HC11.  */
+   and any memory operand for 68HC11.
+   'R' represents indexed addressing mode or access to page0 for 68HC11.
+   For 68HC12, it represents any memory operand.  */
 #define EXTRA_CONSTRAINT(OP, C)                         \
 ((C) == 'U' ? m68hc11_small_indexed_indirect_p (OP, GET_MODE (OP)) \
  : (C) == 'Q' ? m68hc11_symbolic_p (OP, GET_MODE (OP)) \
@@ -1647,6 +1652,7 @@ do {                                    
 {"m68hc11_shift_operator",   {ASHIFT, ASHIFTRT, LSHIFTRT, ROTATE, ROTATERT}},\
 {"m68hc11_eq_compare_operator", {EQ, NE}},                              \
 {"non_push_operand",         {SUBREG, REG, MEM}},			\
+{"splitable_operand",        {SUBREG, REG, MEM}},			\
 {"reg_or_some_mem_operand",  {SUBREG, REG, MEM}},			\
 {"tst_operand",              {SUBREG, REG, MEM}},			\
 {"cmp_operand",              {SUBREG, REG, MEM, SYMBOL_REF, LABEL_REF,	\
Index: config/m68hc11/m68hc11.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/m68hc11/m68hc11.md,v
retrieving revision 1.54.10.5
diff -u -p -r1.54.10.5 m68hc11.md
--- config/m68hc11/m68hc11.md	7 Mar 2004 20:58:29 -0000	1.54.10.5
+++ config/m68hc11/m68hc11.md	6 Jun 2004 13:46:33 -0000
@@ -885,7 +885,7 @@
 }")
 
 (define_insn "movhi_const0"
-  [(set (match_operand:HI 0 "non_push_operand" "=d,A,um")
+  [(set (match_operand:HI 0 "splitable_operand" "=d,A,um")
 	(const_int 0))]
   ""
   "@
@@ -3230,8 +3230,8 @@
 
 (define_insn "*andhi3_gen"
   [(set (match_operand:HI 0 "register_operand" "=d,d,!*A")
-	(and:HI (match_operand:HI 1 "register_operand" "%0,0,0")
-		(match_operand:HI 2 "general_operand" "mi,!u*A,!um*A")))]
+	(and:HI (match_operand:HI 1 "splitable_operand" "%0,0,0")
+		(match_operand:HI 2 "splitable_operand" "mi,!u*A,!um*Ai")))]
   ""
   "*
 {
@@ -3371,7 +3371,7 @@
 (define_expand "iorhi3"
   [(set (match_operand:HI 0 "register_operand" "")
 	(ior:HI (match_operand:HI 1 "register_operand" "")
-		(match_operand:HI 2 "general_operand" "")))]
+		(match_operand:HI 2 "splitable_operand" "")))]
   ""
   "")
 
@@ -3459,8 +3459,8 @@
 
 (define_insn "*iorhi3_gen"
   [(set (match_operand:HI 0 "register_operand" "=d,d,!*A")
-	(ior:HI (match_operand:HI 1 "register_operand" "%0,0,0")
-		(match_operand:HI 2 "general_operand" "mi,!u*A,!um*A")))]
+	(ior:HI (match_operand:HI 1 "splitable_operand" "%0,0,0")
+		(match_operand:HI 2 "splitable_operand" "mi,!u*A,!um*Ai")))]
   ""
   "*
 {
@@ -3589,8 +3589,8 @@
 
 (define_insn "xorhi3"
   [(set (match_operand:HI 0 "register_operand" "=d,d,!*A")
-	(xor:HI (match_operand:HI 1 "register_operand" "%0,0,0")
-		(match_operand:HI 2 "general_operand" "im,!u*A,!ium*A")))]
+	(xor:HI (match_operand:HI 1 "splitable_operand" "%0,0,0")
+		(match_operand:HI 2 "splitable_operand" "im,!u*A,!ium*A")))]
   ""
   "*
 {

Attachment: pgp00000.pgp
Description: PGP signature


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