Commit 3e4f8484 by Georg-Johann Lay Committed by Georg-Johann Lay

re PR target/46779 ([avr] wrong code generation for values held in R28/R29)

	
	PR target/46779
	* config/avr/avr.c (avr_hard_regno_mode_ok): Rewrite.
	In particular, allow 8-bit values in r28 and r29.
	(avr_hard_regno_scratch_ok): Disallow any register that might be
	part of the frame pointer.
	(avr_hard_regno_rename_ok): Same.
	(avr_legitimate_address_p): Don't allow SUBREGs.

From-SVN: r176053
parent 859f6cb4
2011-07-08 Georg-Johann Lay <avr@gjlay.de>
PR target/46779
* config/avr/avr.c (avr_hard_regno_mode_ok): Rewrite.
In particular, allow 8-bit values in r28 and r29.
(avr_hard_regno_scratch_ok): Disallow any register that might be
part of the frame pointer.
(avr_hard_regno_rename_ok): Same.
(avr_legitimate_address_p): Don't allow SUBREGs.
2011-07-08 Julian Brown <julian@codesourcery.com> 2011-07-08 Julian Brown <julian@codesourcery.com>
* config/arm/neon.md (vec_shr_<mode>, vec_shl_<mode>): Disable in * config/arm/neon.md (vec_shr_<mode>, vec_shl_<mode>): Disable in
......
...@@ -1109,8 +1109,7 @@ avr_legitimate_address_p (enum machine_mode mode, rtx x, bool strict) ...@@ -1109,8 +1109,7 @@ avr_legitimate_address_p (enum machine_mode mode, rtx x, bool strict)
true_regnum (XEXP (x, 0))); true_regnum (XEXP (x, 0)));
debug_rtx (x); debug_rtx (x);
} }
if (!strict && GET_CODE (x) == SUBREG)
x = SUBREG_REG (x);
if (REG_P (x) && (strict ? REG_OK_FOR_BASE_STRICT_P (x) if (REG_P (x) && (strict ? REG_OK_FOR_BASE_STRICT_P (x)
: REG_OK_FOR_BASE_NOSTRICT_P (x))) : REG_OK_FOR_BASE_NOSTRICT_P (x)))
r = POINTER_REGS; r = POINTER_REGS;
...@@ -6118,26 +6117,30 @@ jump_over_one_insn_p (rtx insn, rtx dest) ...@@ -6118,26 +6117,30 @@ jump_over_one_insn_p (rtx insn, rtx dest)
int int
avr_hard_regno_mode_ok (int regno, enum machine_mode mode) avr_hard_regno_mode_ok (int regno, enum machine_mode mode)
{ {
/* Disallow QImode in stack pointer regs. */ /* NOTE: 8-bit values must not be disallowed for R28 or R29.
if ((regno == REG_SP || regno == (REG_SP + 1)) && mode == QImode) Disallowing QI et al. in these regs might lead to code like
return 0; (set (subreg:QI (reg:HI 28) n) ...)
which will result in wrong code because reload does not
/* The only thing that can go into registers r28:r29 is a Pmode. */ handle SUBREGs of hard regsisters like this.
if (regno == REG_Y && mode == Pmode) This could be fixed in reload. However, it appears
return 1; that fixing reload is not wanted by reload people. */
/* Otherwise disallow all regno/mode combinations that span r28:r29. */ /* Any GENERAL_REGS register can hold 8-bit values. */
if (regno <= (REG_Y + 1) && (regno + GET_MODE_SIZE (mode)) >= (REG_Y + 1))
return 0; if (GET_MODE_SIZE (mode) == 1)
if (mode == QImode)
return 1; return 1;
/* Modes larger than QImode occupy consecutive registers. */ /* FIXME: Ideally, the following test is not needed.
if (regno + GET_MODE_SIZE (mode) > FIRST_PSEUDO_REGISTER) However, it turned out that it can reduce the number
of spill fails. AVR and it's poor endowment with
address registers is extreme stress test for reload. */
if (GET_MODE_SIZE (mode) >= 4
&& regno >= REG_X)
return 0; return 0;
/* All modes larger than QImode should start in an even register. */ /* All modes larger than 8 bits should start in an even register. */
return !(regno & 1); return !(regno & 1);
} }
...@@ -6410,13 +6413,23 @@ avr_hard_regno_scratch_ok (unsigned int regno) ...@@ -6410,13 +6413,23 @@ avr_hard_regno_scratch_ok (unsigned int regno)
&& !df_regs_ever_live_p (regno)) && !df_regs_ever_live_p (regno))
return false; return false;
/* Don't allow hard registers that might be part of the frame pointer.
Some places in the compiler just test for [HARD_]FRAME_POINTER_REGNUM
and don't care for a frame pointer that spans more than one register. */
if ((!reload_completed || frame_pointer_needed)
&& (regno == REG_Y || regno == REG_Y + 1))
{
return false;
}
return true; return true;
} }
/* Return nonzero if register OLD_REG can be renamed to register NEW_REG. */ /* Return nonzero if register OLD_REG can be renamed to register NEW_REG. */
int int
avr_hard_regno_rename_ok (unsigned int old_reg ATTRIBUTE_UNUSED, avr_hard_regno_rename_ok (unsigned int old_reg,
unsigned int new_reg) unsigned int new_reg)
{ {
/* Interrupt functions can only use registers that have already been /* Interrupt functions can only use registers that have already been
...@@ -6427,6 +6440,17 @@ avr_hard_regno_rename_ok (unsigned int old_reg ATTRIBUTE_UNUSED, ...@@ -6427,6 +6440,17 @@ avr_hard_regno_rename_ok (unsigned int old_reg ATTRIBUTE_UNUSED,
&& !df_regs_ever_live_p (new_reg)) && !df_regs_ever_live_p (new_reg))
return 0; return 0;
/* Don't allow hard registers that might be part of the frame pointer.
Some places in the compiler just test for [HARD_]FRAME_POINTER_REGNUM
and don't care for a frame pointer that spans more than one register. */
if ((!reload_completed || frame_pointer_needed)
&& (old_reg == REG_Y || old_reg == REG_Y + 1
|| new_reg == REG_Y || new_reg == REG_Y + 1))
{
return 0;
}
return 1; return 1;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment