Patchwork [ARM,1/2] Make ARM_LEGITIMIZE_RELOAD_ADDRESS be a function

login
register
mail settings
Submitter Jie Zhang
Date Jan. 30, 2011, 5:03 a.m.
Message ID <4D44F117.4060005@codesourcery.com>
Download mbox | patch
Permalink /patch/81001/
State New
Headers show

Comments

Jie Zhang - Jan. 30, 2011, 5:03 a.m.
On 01/29/2011 11:22 AM, Jie Zhang wrote:
> On 01/29/2011 01:03 AM, Richard Earnshaw wrote:
>> Also, I notice that the same problem has crept into
>> thumb_legitimize_reload_address. Perhaps you could correct that too in
>> a similar manner. Consider such a patch pre-approved (but please commit
>> it separately from the ARM one).
>>
> I will see if I can prepare a patch.
>
I take a look. Yeah, there are some issues in 
thumb_legitimize_reload_address.

1. thumb_legitimize_reload_address uses REG_MODE_OK_FOR_REG_BASE_P, 
which will use an undefined macro ARM_REGNO_OK_FOR_INDEX_P if 
REG_OK_STRICT was defined. But since thumb_legitimize_reload_address is 
defined in arm.c, in which REG_OK_STRICT is not defined, this does not 
cause a compile time bug now.

2. I tried to use REGNO_OK_FOR_INDEX_P instead of 
ARM_REGNO_OK_FOR_INDEX_P and apply the attached patch. GCC would have an 
ICE on the attached test case, which is reduced from a newlib source 
file, with options "-O2 -mthumb".

3. Currently we use thumb_legitimize_reload_address to handle 
TARGET_THUMB1 and TARGET_THUMB2. It seems not good. I think we may need 
to use separate functions for each case.

4. The code piece which uses REG_MODE_OK_FOR_REG_BASE_P in 
thumb_legitimize_reload_address was added to fix PR target/23436. That 
bug cannot be reproduced on the latest GCC trunk even after commenting 
out that code piece. Maybe we don't need that code piece now?

So it seems there is no simple fix for this problem. But I may have not 
much time for this now.


Regards,

Patch

Index: config/arm/arm.c
===================================================================
--- config/arm/arm.c	(revision 169386)
+++ config/arm/arm.c	(working copy)
@@ -6477,8 +6477,8 @@  thumb_legitimize_reload_address (rtx *x_
   if (GET_CODE (x) == PLUS
       && REG_P (XEXP (x, 0))
       && REG_P (XEXP (x, 1))
-      && !REG_MODE_OK_FOR_REG_BASE_P (XEXP (x, 0), mode)
-      && !REG_MODE_OK_FOR_REG_BASE_P (XEXP (x, 1), mode))
+      && !REGNO_OK_FOR_INDEX_P (REGNO (XEXP (x, 0)))
+      && !REGNO_OK_FOR_INDEX_P (REGNO (XEXP (x, 1))))
     {
       rtx orig_x = x;