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] m68k.md: Fix PR target/23435. (Take 3)


Hi,

Attached is a patch to fix PR target/23435.

Consider the testcase, which triggers an unrecognized insn.  This is
because zero_extendsidi2 accepts operands with both being MEM even
though *zero_extendsidi2 does not accept such operands.  (Note that
there are two different patterns zero_extendsidi2 and
*zero_extendsidi2.)

The patch solves this problem by forcing operands[1] to a register if
both operands are MEM.

Tested on m68k-none-elf (modulo execution tests).  Confirmed that the
patch fixed the attached testcase as well as
gcc.c-torture/compile/20010328-1.c.  OK to apply?

Kazu Hirata

2005-11-22  Kazu Hirata  <kazu@codesourcery.com>

	PR target/23435
	* m68k.md (zero_extendsidi2): Force operands[1] to a register
	if both operands[0] and operands[1] are memory.

2005-11-22  Kazu Hirata  <kazu@codesourcery.com>

	PR target/23435
	* gcc.c-torture/compile/pr23435.c: New.

Index: config/m68k/m68k.md
===================================================================
--- config/m68k/m68k.md	(revision 107363)
+++ config/m68k/m68k.md	(working copy)
@@ -1206,8 +1206,12 @@ (define_expand "zero_extendsidi2"
   [(set (match_operand:DI 0 "nonimmediate_operand" "")
 	(zero_extend:DI (match_operand:SI 1 "nonimmediate_src_operand" "")))]
   ""
-  "")
+{
+  if (GET_CODE (operands[0]) == MEM
+      && GET_CODE (operands[1]) == MEM)
+    operands[1] = force_reg (SImode, operands[1]);
+})
 
 (define_insn_and_split "*zero_extendsidi2"
   [(set (match_operand:DI 0 "nonimmediate_operand" "")
--- /dev/null	2005-09-01 09:08:28.063949816 -0700
+++ pr23435.c	2005-11-05 16:06:19.463244152 -0800
@@ -0,0 +1,11 @@
+/* PR target/23435.
+
+   On m68k-none-elf, this used to cause an unrecognized insn because
+   zero_extendsidi2 accepted operands that are both memory even though
+   such a pattern did not exist.  */
+
+void
+foo (unsigned long *a, unsigned long long *p)
+{
+  *p = *a;
+}


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