This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] Remove an unnecessary subreg in combine.
Hi Richard,
> > + /* Here we make sure that we don't have a sign bit on. */
> > + if (nonzero_bits (inner, inner_mode)
> > + < (unsigned HOST_WIDE_INT) 1 << (GET_MODE_BITSIZE (inner_mode) - 1))
>
> Careful -- this fails if inner_mode is wider than HOST_WIDE_INT.
Oh, thanks! I revied the patch as shown below.
Again, regression tested on h8300 port. OK to apply?
Thanks,
Kazu Hirata
Index: combine.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/combine.c,v
retrieving revision 1.292
diff -u -r1.292 combine.c
--- combine.c 23 May 2002 19:23:38 -0000 1.292
+++ combine.c 25 May 2002 03:52:35 -0000
@@ -5160,6 +5160,30 @@
src = SET_SRC (x), dest = SET_DEST (x);
}
+#ifdef HAVE_cc0
+ /* If we have (set (cc0) (subreg ...)), we try to remove the subreg
+ in SRC. */
+ if (dest == cc0_rtx
+ && GET_CODE (src) == SUBREG
+ && subreg_lowpart_p (src)
+ && (GET_MODE_BITSIZE (GET_MODE (src))
+ < GET_MODE_BITSIZE (GET_MODE (SUBREG_REG (src)))))
+ {
+ rtx inner = SUBREG_REG (src);
+ enum machine_mode inner_mode = GET_MODE (inner);
+
+ /* Here we make sure that we don't have a sign bit on. */
+ if (GET_MODE_BITSIZE (inner_mode) <= HOST_BITS_PER_WIDE_INT
+ && (nonzero_bits (inner, inner_mode)
+ < ((unsigned HOST_WIDE_INT) 1
+ << (GET_MODE_BITSIZE (inner_mode) - 1))))
+ {
+ SUBST (SET_SRC (x), inner);
+ src = SET_SRC (x);
+ }
+ }
+#endif
+
#ifdef LOAD_EXTEND_OP
/* If we have (set FOO (subreg:M (mem:N BAR) 0)) with M wider than N, this
would require a paradoxical subreg. Replace the subreg with a