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]

Re: Reload related segfaults


> The crash is in find_valid_class() called from push_reload(), via this
> code block around line 1184 of reload.c:
>
>       enum reg_class in_out_class
> 	= find_valid_class (outmode, GET_MODE (SUBREG_REG (out)),
> 			    subreg_regno_offset (REGNO (SUBREG_REG (out)),
> 						 GET_MODE (SUBREG_REG (out)),
> 						 SUBREG_BYTE (out),
> 						 GET_MODE (out)),
> 			    REGNO (SUBREG_REG (out)));
>
> 'out' is:
>
> (subreg:DI (reg/v:V4QI 50 %f18 [orig:314 s2hi4_ ] [314]) 0)
>
> so subreg_regno_offset() returns -1, and find_valid_class() isn't too happy
> about getting "-1" for it's 'n' argument.

OK, Alan's case is the same-sized and yours is the paradoxical one.  Clearly we 
shouldn't have tried to change anything for them.

Tentative fix attached, it should restore the old behavior for the cases where 
everything was working fine before.  I'm going to give it some testing.


	PR rtl-optimization/46603
	* reload.c (push_reload): In the out case, restore previous behavior
	for subregs that don't have word mode.


-- 
Eric Botcazou
Index: reload.c
===================================================================
--- reload.c	(revision 180526)
+++ reload.c	(working copy)
@@ -1140,6 +1140,14 @@ push_reload (rtx in, rtx out, rtx *inloc
 			   / UNITS_PER_WORD)))
 #endif
 		  ))
+	  || (REG_P (SUBREG_REG (out))
+	      && REGNO (SUBREG_REG (out)) < FIRST_PSEUDO_REGISTER
+	      /* The case of a word mode subreg
+		 is handled differently in the following statement.  */
+	      && ! (GET_MODE_SIZE (outmode) <= UNITS_PER_WORD
+		    && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (out)))
+		        > UNITS_PER_WORD))
+	      && ! HARD_REGNO_MODE_OK (subreg_regno (out), outmode))
 	  || (secondary_reload_class (0, rclass, outmode, out) != NO_REGS
 	      && (secondary_reload_class (0, rclass, GET_MODE (SUBREG_REG (out)),
 					  SUBREG_REG (out))

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