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] h8300.md: Fix *andor[qhs]i3.


Hi,

Attached is a patch to fix *andor[qhs]i3.

The *andor[qhs]i3 patterns are used for a piece of code like

  A |= B & 1;

In this example, gcc without the patch loads the LSB of B and stores
that to the LSB of A without ORing it with the LSB of A.  The patch
fixes the problem by adding this ORing.

Tested on h8300.  Committed.

A testcase will follow shortly.

Kazu Hirata

2002-11-18  Kazu Hirata  <kazu@cs.umass.edu>

	* config/h8300/h8300.md (*andorqi3): Use bor between bld and
	bst.  Update the insn length.
	(*andorhi3): Likewise.
	(*andorsi3): Likewise.

Index: h8300.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.md,v
retrieving revision 1.105
diff -u -r1.105 h8300.md
--- h8300.md	17 Nov 2002 23:32:45 -0000	1.105
+++ h8300.md	18 Nov 2002 16:21:48 -0000
@@ -1095,8 +1095,8 @@
 			(match_operand:QI 3 "single_one_operand" "n"))
 		(match_operand:QI 1 "register_operand" "0")))]
   ""
-  "bld\\t%V3,%X2\;bst\\t%V3,%X0"
-  [(set_attr "length" "4")
+  "bld\\t%V3,%X2\;bor\\t%V3,%X0\;bst\\t%V3,%X0"
+  [(set_attr "length" "6")
    (set_attr "cc" "clobber")])
 
 (define_insn "*andorhi3"
@@ -1111,11 +1111,11 @@
   if (INTVAL (operands[3]) > 128)
     {
       operands[3] = GEN_INT (INTVAL (operands[3]) >> 8);
-      return \"bld\\t%V3,%t2\;bst\\t%V3,%t0\";
+      return \"bld\\t%V3,%t2\;bor\\t%V3,%t0\;bst\\t%V3,%t0\";
     }
-  return \"bld\\t%V3,%s2\;bst\\t%V3,%s0\";
+  return \"bld\\t%V3,%s2\;bor\\t%V3,%s0\;bst\\t%V3,%s0\";
 }"
-  [(set_attr "length" "4")
+  [(set_attr "length" "6")
    (set_attr "cc" "clobber")])
 
 (define_insn "*andorsi3"
@@ -1130,11 +1130,11 @@
   if (INTVAL (operands[3]) > 128)
     {
       operands[3] = GEN_INT (INTVAL (operands[3]) >> 8);
-      return \"bld\\t%V3,%x2\;bst\\t%V3,%x0\";
+      return \"bld\\t%V3,%x2\;bor\\t%V3,%x0\;bst\\t%V3,%x0\";
     }
-  return \"bld\\t%V3,%w2\;bst\\t%V3,%w0\";
+  return \"bld\\t%V3,%w2\;bor\\t%V3,%w0\;bst\\t%V3,%w0\";
 }"
-  [(set_attr "length" "4")
+  [(set_attr "length" "6")
    (set_attr "cc" "clobber")])
 
 (define_expand "andsi3"


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