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]

gen_lowpart_no_emit, part 2


This patch improves on the gen_lowpart_no_emit patch:
- it merges gen_lowpart_if_possible and the generic implementation of gen_lowpart_no_emit
- it makes combine use gen_lowpart_for_combine also for the gen_lowpart_no_emit hook.


Bootstrapped/regtested powerpc-apple-darwin7.8.0, ok for mainline?

Paolo

2004-03-21  Paolo Bonzini  <bonzini@gnu.org>

	* combine.c (RTL_HOOKS_GEN_LOWPART_NO_EMIT): Use
	gen_lowpart_for_combine.
	* cse.c (gen_lowpart_if_possible): Move...
	* rtlhooks.c (gen_lowpart_if_possible): ... here.  Also try
	gen_lowpart_SUBREG.
	(gen_lowpart_no_emit_general): Use it.

Index: combine.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/combine.c,v
retrieving revision 1.483
diff -p -u -r1.483 combine.c
--- combine.c	21 Mar 2005 14:37:58 -0000	1.483
+++ combine.c	21 Mar 2005 15:08:29 -0000
@@ -422,6 +422,10 @@ static bool unmentioned_reg_p (rtx, rtx)
 #undef RTL_HOOKS_GEN_LOWPART
 #define RTL_HOOKS_GEN_LOWPART              gen_lowpart_for_combine
 
+/* Our implementation of gen_lowpart never emits a new pseudo.  */
+#undef RTL_HOOKS_GEN_LOWPART_NO_EMIT
+#define RTL_HOOKS_GEN_LOWPART_NO_EMIT      gen_lowpart_for_combine
+
 #undef RTL_HOOKS_REG_NONZERO_REG_BITS
 #define RTL_HOOKS_REG_NONZERO_REG_BITS     reg_nonzero_bits_for_combine
 
Index: cse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cse.c,v
retrieving revision 1.350
diff -p -u -r1.350 cse.c
--- cse.c	14 Mar 2005 20:06:05 -0000	1.350
+++ cse.c	21 Mar 2005 15:08:17 -0000
@@ -4344,48 +4343,7 @@ equiv_constant (rtx x)
   return 0;
 }
 
-/* Assuming that X is an rtx (e.g., MEM, REG or SUBREG) for a fixed-point
-   number, return an rtx (MEM, SUBREG, or CONST_INT) that refers to the
-   least-significant part of X.
-   MODE specifies how big a part of X to return.
-
-   If the requested operation cannot be done, 0 is returned.
-
-   This is similar to gen_lowpart_general in emit-rtl.c.  */
-
-rtx
-gen_lowpart_if_possible (enum machine_mode mode, rtx x)
-{
-  rtx result = gen_lowpart_common (mode, x);
-
-  if (result)
-    return result;
-  else if (MEM_P (x))
-    {
-      /* This is the only other case we handle.  */
-      int offset = 0;
-      rtx new;
-
-      if (WORDS_BIG_ENDIAN)
-	offset = (MAX (GET_MODE_SIZE (GET_MODE (x)), UNITS_PER_WORD)
-		  - MAX (GET_MODE_SIZE (mode), UNITS_PER_WORD));
-      if (BYTES_BIG_ENDIAN)
-	/* Adjust the address so that the address-after-the-data is
-	   unchanged.  */
-	offset -= (MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode))
-		   - MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (x))));
-
-      new = adjust_address_nv (x, mode, offset);
-      if (! memory_address_p (mode, XEXP (new, 0)))
-	return 0;
-
-      return new;
-    }
-  else
-    return 0;
-}
-
 /* Given INSN, a jump insn, PATH_TAKEN indicates if we are following the "taken"
    branch.  It will be zero if not.
 
    In certain cases, this can cause us to add an equivalence.  For example,
Index: rtlhooks.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtlhooks.c,v
retrieving revision 2.6
diff -p -u -r2.6 rtlhooks.c
--- rtlhooks.c	21 Mar 2005 14:29:46 -0000	2.6
+++ rtlhooks.c	23 Mar 2005 12:58:05 -0000
@@ -25,6 +25,7 @@ Software Foundation, 59 Temple Place - S
 #include "rtl.h"
 #include "rtlhooks-def.h"
 #include "expr.h"
+#include "recog.h"
 
 
 /* For speed, we will copy the RTX hooks struct member-by-member
@@ -84,12 +85,11 @@ gen_lowpart_general (enum machine_mode m
 rtx
 gen_lowpart_no_emit_general (enum machine_mode mode, rtx x)
 {
-  rtx result = gen_lowpart_common (mode, x);
+  rtx result = gen_lowpart_if_possible (mode, x);
   if (result)
     return result;
-  if (mode != GET_MODE (x) && GET_MODE (x) != VOIDmode)
-    return gen_lowpart_SUBREG (mode, x);
-  return x;
+  else
+    return x;
 }
 
 rtx
@@ -113,3 +113,47 @@ reg_nonzero_bits_general (rtx x ATTRIBUT
 {
   return NULL;
 }
+
+/* Assuming that X is an rtx (e.g., MEM, REG or SUBREG) for a fixed-point
+   number, return an rtx (MEM, SUBREG, or CONST_INT) that refers to the
+   least-significant part of X.
+   MODE specifies how big a part of X to return.
+
+   If the requested operation cannot be done, 0 is returned.
+
+   This is similar to gen_lowpart_general.  */
+
+rtx
+gen_lowpart_if_possible (enum machine_mode mode, rtx x)
+{
+  rtx result = gen_lowpart_common (mode, x);
+
+  if (result)
+    return result;
+  else if (MEM_P (x))
+    {
+      /* This is the only other case we handle.  */
+      int offset = 0;
+      rtx new;
+
+      if (WORDS_BIG_ENDIAN)
+	offset = (MAX (GET_MODE_SIZE (GET_MODE (x)), UNITS_PER_WORD)
+		  - MAX (GET_MODE_SIZE (mode), UNITS_PER_WORD));
+      if (BYTES_BIG_ENDIAN)
+	/* Adjust the address so that the address-after-the-data is
+	   unchanged.  */
+	offset -= (MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode))
+		   - MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (x))));
+
+      new = adjust_address_nv (x, mode, offset);
+      if (! memory_address_p (mode, XEXP (new, 0)))
+	return 0;
+
+      return new;
+    }
+  else if (mode != GET_MODE (x) && GET_MODE (x) != VOIDmode)
+    return gen_lowpart_SUBREG (mode, x);
+  else
+    return 0;
+}
+

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