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 COMMITTED: Handle SUBREG in elim_reg_cond in flow.c


While doing some testing with --enable-checking=rtl, I discovered that
some code in flow gets an RTL checking error.  This is in
elim_reg_cond:

  if (COMPARISON_P (x))
    {
      if (REGNO (XEXP (reg) == regno)
	return const0_rtx;
      return x;
    }

X here can come from init_propagate_block_info, which does this:

	  if (GET_CODE (reg) == SUBREG)
	    reg = SUBREG_REG (reg);
        ...
 	  if (inv_cond != UNKNOWN
 	      && REG_P (reg)
	      && XEXP (cond_true, 1) == const0_rtx)
	    {

so it can have a subreg in the condition.  Those the code above can
ask for the REGNO of a SUBREG.  Without checking enabled the test does
the wrong thing, but does little harm in practice.

This patch fixes the problem.  Bootstrapped and tested on
i686-pc-linux-gnu.  Committed.

Ian


2007-04-24  Ian Lance Taylor  <iant@google.com>

	* flow.c (elim_reg_cond): Handle a comparison of a subreg.


Index: flow.c
===================================================================
--- flow.c	(revision 124119)
+++ flow.c	(working copy)
@@ -3437,7 +3437,13 @@ elim_reg_cond (rtx x, unsigned int regno
 
   if (COMPARISON_P (x))
     {
-      if (REGNO (XEXP (x, 0)) == regno)
+      rtx reg;
+
+      reg = XEXP (x, 0);
+      if (GET_CODE (reg) == SUBREG)
+	reg = SUBREG_REG (reg);
+      gcc_assert (REG_P (reg));
+      if (REGNO (reg) == regno)
 	return const0_rtx;
       return x;
     }


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