This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Reload fixes for EXTRA_MEMORY_CONSTRAINT problems
- From: "Ulrich Weigand" <Ulrich dot Weigand at de dot ibm dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 19 Nov 2002 18:36:14 +0100
- Subject: [PATCH] Reload fixes for EXTRA_MEMORY_CONSTRAINT problems
- Sensitivity:
Hello,
while experimenting with exploiting the new EXTRA_MEMORY_CONSTRAINT
and EXTRA_ADDRESS_CONSTRAINT features better, I've found two problems:
- In constrain_operands, if an alternative matches exactly, it should
be preferred over an EXTRA_MEMORY_CONSTRAINT/EXTRA_ADDRESS_CONSTRAINT
alternative that doesn't match exactly but can be reloaded.
- In find_reloads, if an EXTRA_ADDRESS_CONSTRAINT operand is to be
reloaded, the reload should use Pmode instead of the operand mode
specified in the insn (which means something else for address operands).
While I don't have test cases that fail due to these problems with
the current code, I think they should still be fixed. In some cases,
I do get slightly better code due to the constrain_operands fix even
now.
Bootstrapped/regtested on s390-ibm-linux and s390x-ibm-linux (the
only platforms currently using EXTRA_MEMORY_CONSTRAINT).
OK to apply?
ChangeLog:
* recog.c (constrain_operands): Prefer exact match over reloadable
EXTRA_MEMORY_CONSTRAINT or EXTRA_ADDRESS_CONSTRAINT.
* reload.c (find_reloads): Always reload EXTRA_ADDRESS_CONSTRAINT
operands in Pmode.
Index: gcc/recog.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/recog.c,v
retrieving revision 1.167
diff -c -p -r1.167 recog.c
*** gcc/recog.c 11 Nov 2002 05:38:22 -0000 1.167
--- gcc/recog.c 19 Nov 2002 15:09:32 -0000
*************** constrain_operands (strict)
*** 2628,2650 ****
if (EXTRA_MEMORY_CONSTRAINT (c))
{
! /* Every memory operand can be reloaded to fit,
! so copy the condition from the 'm' case. */
! if (GET_CODE (op) == MEM
! /* Before reload, accept what reload can turn into mem. */
! || (strict < 0 && CONSTANT_P (op))
! /* During reload, accept a pseudo */
! || (reload_in_progress && GET_CODE (op) == REG
! && REGNO (op) >= FIRST_PSEUDO_REGISTER))
win = 1;
}
if (EXTRA_ADDRESS_CONSTRAINT (c))
{
! /* Every address operand can be reloaded to fit,
! so copy the condition from the 'p' case. */
! if (strict <= 0
! || (strict_memory_address_p (recog_data.operand_mode[opno],
! op)))
win = 1;
}
#endif
--- 2628,2650 ----
if (EXTRA_MEMORY_CONSTRAINT (c))
{
! /* Every memory operand can be reloaded to fit. */
! if (strict < 0 && GET_CODE (op) == MEM)
! win = 1;
!
! /* Before reload, accept what reload can turn into mem. */
! if (strict < 0 && CONSTANT_P (op))
! win = 1;
!
! /* During reload, accept a pseudo */
! if (reload_in_progress && GET_CODE (op) == REG
! && REGNO (op) >= FIRST_PSEUDO_REGISTER)
win = 1;
}
if (EXTRA_ADDRESS_CONSTRAINT (c))
{
! /* Every address operand can be reloaded to fit. */
! if (strict < 0)
win = 1;
}
#endif
Index: gcc/reload.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/reload.c,v
retrieving revision 1.197
diff -c -p -r1.197 reload.c
*** gcc/reload.c 4 Nov 2002 16:57:02 -0000 1.197
--- gcc/reload.c 19 Nov 2002 15:09:36 -0000
*************** find_reloads (insn, replace, ind_levels,
*** 3283,3288 ****
--- 3283,3292 ----
the address into a base register. */
this_alternative[i] = (int) MODE_BASE_REG_CLASS (VOIDmode);
badop = 0;
+
+ /* Address constraints are reloaded in Pmode, no matter
+ what mode is given in the machine description. */
+ operand_mode[i] = Pmode;
break;
}
Mit freundlichen Gruessen / Best Regards
Ulrich Weigand
--
Dr. Ulrich Weigand
Linux for S/390 Design & Development
IBM Deutschland Entwicklung GmbH, Schoenaicher Str. 220, 71032 Boeblingen
Phone: +49-7031/16-3727 --- Email: Ulrich.Weigand@de.ibm.com