This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PR 34995: EXTRA_MEMORY_CONSTRAINTs and constant addresses
- From: Richard Sandiford <rsandifo at nildram dot co dot uk>
- To: Ian Lance Taylor <iant at google dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 31 Jan 2008 09:27:11 +0000
- Subject: Re: PR 34995: EXTRA_MEMORY_CONSTRAINTs and constant addresses
- References: <874pcva6mm.fsf@firetop.home> <m3abmnl3ga.fsf@localhost.localdomain>
Ian Lance Taylor <iant@google.com> writes:
> Richard Sandiford <rsandifo@nildram.co.uk> writes:
>
>> gcc/
>> PR rtl-optimization/34995
>> * reload.c (alternative_allows_const_pool_ref): Take an rtx
>> parameter and return a bool. If the rtx parameter is nonnull,
>> check that it satisfies an EXTRA_MEMORY_CONSTRAINT.
>> (find_reloads): Update call accordingly. Pass the new operand
>> if it needed no address reloads, otherwise pass null.
>
>> + if (c == 'm'
>> + || c == 'o'
>> + || (EXTRA_MEMORY_CONSTRAINT (c, constraint)
>> + && (mem == NULL || EXTRA_CONSTRAINT_STR (mem, c, constraint))))
>> + return true;
>> + return false;
>
> You need to protect the use of EXTRA_CONSTRAINT_STR with #ifdef
> EXTRA_CONSTRAINT_STR.
Oops, good catch.
> This is OK with that change.
Thanks, here's what I checked in after retesting.
Richard
gcc/
PR rtl-optimization/34995
* reload.c (alternative_allows_const_pool_ref): Take an rtx
parameter and return a bool. If the rtx parameter is nonnull,
check that it satisfies an EXTRA_MEMORY_CONSTRAINT.
(find_reloads): Update call accordingly. Pass the new operand
if it needed no address reloads, otherwise pass null.
Index: gcc/reload.c
===================================================================
--- gcc/reload.c (revision 131959)
+++ gcc/reload.c (working copy)
@@ -263,7 +263,7 @@ static rtx find_dummy_reload (rtx, rtx,
static int hard_reg_set_here_p (unsigned int, unsigned int, rtx);
static struct decomposition decompose (rtx);
static int immune_p (rtx, rtx, struct decomposition);
-static int alternative_allows_memconst (const char *, int);
+static bool alternative_allows_const_pool_ref (rtx, const char *, int);
static rtx find_reloads_toplev (rtx, int, enum reload_type, int, int, rtx,
int *);
static rtx make_memloc (rtx, int);
@@ -3836,13 +3836,19 @@ find_reloads (rtx insn, int replace, int
|| no_input_reloads)
&& operand_mode[i] != VOIDmode)
{
+ int this_address_reloaded;
+
+ this_address_reloaded = 0;
substed_operand[i] = recog_data.operand[i]
= find_reloads_toplev (force_const_mem (operand_mode[i],
recog_data.operand[i]),
i, address_type[i], ind_levels, 0, insn,
- NULL);
- if (alternative_allows_memconst (recog_data.constraints[i],
- goal_alternative_number))
+ &this_address_reloaded);
+ if (alternative_allows_const_pool_ref (this_address_reloaded == 0
+ ? substed_operand[i]
+ : NULL,
+ recog_data.constraints[i],
+ goal_alternative_number))
goal_alternative_win[i] = 1;
}
@@ -4498,13 +4504,16 @@ find_reloads (rtx insn, int replace, int
return retval;
}
-/* Return 1 if alternative number ALTNUM in constraint-string CONSTRAINT
- accepts a memory operand with constant address. */
+/* Return true if alternative number ALTNUM in constraint-string
+ CONSTRAINT is guaranteed to accept a reloaded constant-pool reference.
+ MEM gives the reference if it didn't need any reloads, otherwise it
+ is null. */
-static int
-alternative_allows_memconst (const char *constraint, int altnum)
+static bool
+alternative_allows_const_pool_ref (rtx mem, const char *constraint, int altnum)
{
int c;
+
/* Skip alternatives before the one requested. */
while (altnum > 0)
{
@@ -4512,12 +4521,25 @@ alternative_allows_memconst (const char
altnum--;
}
/* Scan the requested alternative for 'm' or 'o'.
- If one of them is present, this alternative accepts memory constants. */
+ If one of them is present, this alternative accepts the result of
+ passing a constant-pool reference through find_reloads_toplev.
+
+ The same is true of extra memory constraints if the address
+ was reloaded into a register. However, the target may elect
+ to disallow the original constant address, forcing it to be
+ reloaded into a register instead. */
for (; (c = *constraint) && c != ',' && c != '#';
constraint += CONSTRAINT_LEN (c, constraint))
- if (c == 'm' || c == 'o' || EXTRA_MEMORY_CONSTRAINT (c, constraint))
- return 1;
- return 0;
+ {
+ if (c == 'm' || c == 'o')
+ return true;
+#ifdef EXTRA_CONSTRAINT_STR
+ if (EXTRA_MEMORY_CONSTRAINT (c, constraint)
+ && (mem == NULL || EXTRA_CONSTRAINT_STR (mem, c, constraint)))
+ return true;
+#endif
+ }
+ return false;
}
/* Scan X for memory references and scan the addresses for reloading.