[patch] h8300.c: Fix the predicates general_operand_{src,dst}.

Kazu Hirata kazu@cs.umass.edu
Wed Feb 19 04:37:00 GMT 2003


Hi,

Attached is a patch to fix the predicates general_operand_src and
general_operand_dst in h8300.c.  Specifically, they ignore mode when
op is a (mem (post_inc ...)).  This causes the recognizer to
malfunction.  For example, given a pattern for extendhisi, the
recognizer returns insn_code_number for extendqisi, resulting in wrong
code.

Tested on h8300 port.  Committed.

Kazu Hirata

2003-02-18  Kazu Hirata  <kazu@cs.umass.edu>

	* config/h8300/h8300.c (general_operand_src): Always check
	MODE.
	(general_operand_dst): Likewise.

2003-02-18  Kazu Hirata  <kazu@cs.umass.edu>

	* gcc.c-torture/execute/20030218-1.c: New.

Index: h8300.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.c,v
retrieving revision 1.212
diff -u -r1.212 h8300.c
--- h8300.c	11 Feb 2003 13:43:20 -0000	1.212
+++ h8300.c	19 Feb 2003 02:22:20 -0000
@@ -723,7 +723,9 @@
      rtx op;
      enum machine_mode mode;
 {
-  if (GET_CODE (op) == MEM && GET_CODE (XEXP (op, 0)) == POST_INC)
+  if (GET_MODE (op) == mode
+      && GET_CODE (op) == MEM
+      && GET_CODE (XEXP (op, 0)) == POST_INC)
     return 1;
   return general_operand (op, mode);
 }
@@ -736,7 +738,9 @@
      rtx op;
      enum machine_mode mode;
 {
-  if (GET_CODE (op) == MEM && GET_CODE (XEXP (op, 0)) == PRE_DEC)
+  if (GET_MODE (op) == mode
+      && GET_CODE (op) == MEM
+      && GET_CODE (XEXP (op, 0)) == PRE_DEC)
     return 1;
   return general_operand (op, mode);
 }
Index: 20030218-1.c
===================================================================
RCS file: 20030218-1.c
diff -N 20030218-1.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ 20030218-1.c	19 Feb 2003 02:31:53 -0000
@@ -0,0 +1,25 @@
+/*  On H8, the predicate general_operand_src(op,mode) used to ignore
+    mode when op is a (mem (post_inc ...)).  As a result, the pattern
+    for extendhisi2 was recognized as extendqisi2.  */
+
+extern void abort ();
+extern void exit (int);
+
+short *q;
+
+long
+foo (short *p)
+{
+  long b = *p;
+  q = p + 1;
+  return b;
+}
+
+int
+main ()
+{
+  short a = 0xff00;
+  if (foo (&a) != (long) (short) 0xff00)
+    abort ();
+  exit (0);
+}



More information about the Gcc-patches mailing list