From a6e8d1139de77569a6dfaba1dda8b223afc278a7 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu@cs.umass.edu>
Date: Mon, 30 Dec 2002 15:28:31 +0000
Subject: [PATCH] h8300.c (output_logical_op): Use extu.w if we are clearing
 the most significant byte.

	* config/h8300/h8300.c (output_logical_op): Use extu.w if we
	are clearing the most significant byte.
	(compute_logical_op_length): Update to reflect the change in
	output_logical_op.
	(compute_logical_op_cc): Likewise.

From-SVN: r60632
---
 gcc/ChangeLog            |  8 ++++++++
 gcc/config/h8300/h8300.c | 25 ++++++++++++++++++++++---
 2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 74e2a1a551e6..022ef307130a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2002-12-30  Kazu Hirata  <kazu@cs.umass.edu>
+
+	* config/h8300/h8300.c (output_logical_op): Use extu.w if we
+	are clearing the most significant byte.
+	(compute_logical_op_length): Update to reflect the change in
+	output_logical_op.
+	(compute_logical_op_cc): Likewise.
+
 2002-12-29  Kazu Hirata  <kazu@cs.umass.edu>
 
 	* config/h8300/h8300.md: Give internal names to anonymous
diff --git a/gcc/config/h8300/h8300.c b/gcc/config/h8300/h8300.c
index afa43c14b54f..e77edaf82a22 100644
--- a/gcc/config/h8300/h8300.c
+++ b/gcc/config/h8300/h8300.c
@@ -2151,7 +2151,9 @@ output_logical_op (mode, operands)
 	  && ((det & 0x0000ffff) != 0)
 	  && ((det & 0xffff0000) != 0)
 	  && (code == IOR || det != 0xffffff00)
-	  && (code == IOR || det != 0xffff00ff))
+	  && (code == IOR || det != 0xffff00ff)
+	  && (code != AND || det != 0xff00ff00)
+	  && (code != AND || det != 0xff0000ff))
 	{
 	  sprintf (insn_buf, "%s.l\t%%S2,%%S0", opname);
 	  output_asm_insn (insn_buf, operands);
@@ -2195,6 +2197,13 @@ output_logical_op (mode, operands)
 	    output_asm_insn ((code == AND)
 			     ? "sub.w\t%e0,%e0" : "not.w\t%e0",
 			     operands);
+	  else if ((TARGET_H8300H || TARGET_H8300S)
+		   && code == AND
+		   && (det & 0xffff0000) == 0xff000000)
+	    {
+	      sprintf (insn_buf, "extu.w\t%%e0", opname);
+	      output_asm_insn (insn_buf, operands);
+	    }
 	  else if (TARGET_H8300H || TARGET_H8300S)
 	    {
 	      if ((det & 0xffff0000) != 0)
@@ -2275,7 +2284,9 @@ compute_logical_op_length (mode, operands)
 	  && ((det & 0x0000ffff) != 0)
 	  && ((det & 0xffff0000) != 0)
 	  && (code == IOR || det != 0xffffff00)
-	  && (code == IOR || det != 0xffff00ff))
+	  && (code == IOR || det != 0xffff00ff)
+	  && (code != AND || det != 0xff00ff00)
+	  && (code != AND || det != 0xff0000ff))
 	{
 	  if (REG_P (operands[2]))
 	    length += 4;
@@ -2315,6 +2326,12 @@ compute_logical_op_length (mode, operands)
 	    {
 	      length += 2;
 	    }
+	  else if ((TARGET_H8300H || TARGET_H8300S)
+		   && code == AND
+		   && (det & 0xffff0000) == 0xff000000)
+	    {
+	      length += 2;
+	    }
 	  else if (TARGET_H8300H || TARGET_H8300S)
 	    {
 	      if ((det & 0xffff0000) != 0)
@@ -2374,7 +2391,9 @@ compute_logical_op_cc (mode, operands)
 	  && ((det & 0x0000ffff) != 0)
 	  && ((det & 0xffff0000) != 0)
 	  && (code == IOR || det != 0xffffff00)
-	  && (code == IOR || det != 0xffff00ff))
+	  && (code == IOR || det != 0xffff00ff)
+	  && (code != AND || det != 0xff00ff00)
+	  && (code != AND || det != 0xff0000ff))
 	{
 	  cc = CC_SET_ZNV;
 	}
-- 
GitLab