[RFC] Fix PR rtl-optimization/33732

Rask Ingemann Lambertsen rask@sygehus.dk
Thu Nov 8 16:39:00 GMT 2007


On Thu, Nov 08, 2007 at 10:21:47AM +0100, Paolo Bonzini wrote:

> I didn't understand if the fixes you proposed are "interesting" even 
> without adding the additional scan.  Even if they are not, they might be 
> real bugs, so we may consider them for next stage1.

   The situation where we have a subreg of a multiword hard reg
probably only happens in reload between the alter_reg() loop and the
cleanup_subreg_operands() loop. Everybody else should be using
simplify_gen_subreg() and then it won't happen. So the fixes fix cases that
DF isn't really supposed to see in the first place.

> >   I can see a few ways to fix this:
> >
> 
> What about...
> 
> >1) Pass NULL for LOC to df_ref_create_structure().
> 
> ... only if it "would be a bad idea to use DF_REF_REAL_LOC"? As in:
> 
>  rtx *ref_loc;
>  rtx *real_loc = REG_P (*loc) ? loc : &SUBREG_REG (*loc);
>  if (GET_MODE (*real_loc) != GET_MODE (regno_reg_rtx[i]))
>    ref_loc = loc;
>  else
>    ref_loc = NULL;
> 
>  ref = df_ref_create_structure (collection_rec, regno_reg_rtx[i],
>                                 ref_loc, bb, insn, ref_type, ref_flags);
> 
> You also do the HARD_REGISTER_P check in the right place (this part of 
> df-scan is only run for hard regs).

   Right. What we probably really want to check is if the number of hard
regs is the same rather than checking if the mode is the same. It is always
1 for regno_reg_rtx[i].

Index: gcc/df-scan.c
===================================================================
--- gcc/df-scan.c	(revision 129849)
+++ gcc/df-scan.c	(working copy)
@@ -2675,8 +2675,20 @@ df_ref_record (struct df_collection_rec 
 
       for (i = regno; i < endregno; i++)
 	{
-	  ref = df_ref_create_structure (collection_rec, regno_reg_rtx[i], loc, 
-					 bb, insn, ref_type, ref_flags);
+	  rtx *ref_loc;
+	  if (loc)
+	    {
+	      rtx *real_loc = REG_P (*loc) ? loc : &SUBREG_REG (*loc);
+	      if (hard_regno_nregs[REGNO (*real_loc)][GET_MODE (*real_loc)] == 1)
+		ref_loc = loc;
+	      else
+		ref_loc = NULL;
+	    }
+	  else
+	    ref_loc = NULL;
+	  ref = df_ref_create_structure (collection_rec, regno_reg_rtx[i],
+					 ref_loc, bb, insn, ref_type,
+					 ref_flags);
 
           gcc_assert (ORIGINAL_REGNO (DF_REF_REG (ref)) == i);
 	}

   Hmm. This probably should use subreg_nregs() for the SUBREG case.

-- 
Rask Ingemann Lambertsen
Danish law requires addresses in e-mail to be logged and stored for a year



More information about the Gcc-patches mailing list