diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 7c091ed4d3a6a81cb4db8c6808d1a144a9907b71..8d8098fb4ba93a7a7cd1fa230fbf6542c9b82e85 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 in more
+	cases.
+	(compute_logical_op_length): Update to reflect the change in
+	output_logical_op.
+	(compute_logical_op_cc): Likewise.
+
 2002-12-30  Joseph S. Myers  <jsm@polyomino.org.uk>
 
 	* doc/service.texi: Uncomment and update FAQ link.
diff --git a/gcc/config/h8300/h8300.c b/gcc/config/h8300/h8300.c
index e77edaf82a22e8aa70757dd5b5e7c87ac87f826d..baa50bb29a53fa18430af2c243e7288ed9b8b57d 100644
--- a/gcc/config/h8300/h8300.c
+++ b/gcc/config/h8300/h8300.c
@@ -2152,8 +2152,10 @@ output_logical_op (mode, operands)
 	  && ((det & 0xffff0000) != 0)
 	  && (code == IOR || det != 0xffffff00)
 	  && (code == IOR || det != 0xffff00ff)
-	  && (code != AND || det != 0xff00ff00)
-	  && (code != AND || det != 0xff0000ff))
+	  && !(code == AND
+	       && (det == 0xff00ffff
+		   || (det & 0xffff00ff) == 0xff000000
+		   || (det & 0xffffff00) == 0xff000000)))
 	{
 	  sprintf (insn_buf, "%s.l\t%%S2,%%S0", opname);
 	  output_asm_insn (insn_buf, operands);
@@ -2285,8 +2287,10 @@ compute_logical_op_length (mode, operands)
 	  && ((det & 0xffff0000) != 0)
 	  && (code == IOR || det != 0xffffff00)
 	  && (code == IOR || det != 0xffff00ff)
-	  && (code != AND || det != 0xff00ff00)
-	  && (code != AND || det != 0xff0000ff))
+	  && !(code == AND
+	       && (det == 0xff00ffff
+		   || (det & 0xffff00ff) == 0xff000000
+		   || (det & 0xffffff00) == 0xff000000)))
 	{
 	  if (REG_P (operands[2]))
 	    length += 4;
@@ -2392,8 +2396,10 @@ compute_logical_op_cc (mode, operands)
 	  && ((det & 0xffff0000) != 0)
 	  && (code == IOR || det != 0xffffff00)
 	  && (code == IOR || det != 0xffff00ff)
-	  && (code != AND || det != 0xff00ff00)
-	  && (code != AND || det != 0xff0000ff))
+	  && !(code == AND
+	       && (det == 0xff00ffff
+		   || (det & 0xffff00ff) == 0xff000000
+		   || (det & 0xffffff00) == 0xff000000)))
 	{
 	  cc = CC_SET_ZNV;
 	}