On Mon, Jul 18, 2011 at 1:33 PM, Uros Bizjak <ubiz...@gmail.com> wrote:
> On Mon, Jul 18, 2011 at 10:25 PM, H.J. Lu <hjl.to...@gmail.com> wrote:
>
>>>>>> TARGET_MEM_REF only works on ptr_mode.   This patch allows 32bit address
>>>>>> in x32 mode.  OK for trunk?
>>>>>
>>>>> Do you perhaps have a testcase to help in analyzing the problem?
>>>>>
>>>>
>>>> See:
>>>>
>>>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49780
>>>
>>> I don't think that tree-ssa-address/addr_for_mem_ref is correct when
>>> REALLY_EXPAND is false. It constructs RTX "template" in pointer_mode,
>>> which is not necessary valid and is rejected from
>>> ix86_validate_address_p. When really expanding the expression, we have
>>> a conversion at the end:
>>>
>>>  gen_addr_rtx (pointer_mode, sym, bse, idx, st, off, &address, NULL, NULL);
>>>  if (pointer_mode != address_mode)
>>>    address = convert_memory_address (address_mode, address);
>>>  return address;
>>>
>>> This is in fact your r175912 change in the fix for PR47383 - you need
>>> to do something with template as well...
>>>
>>
>> Since TARGET_MEM_REF only works on ptr_mode, I don't think
>> we can change template.  We just need to accept TARGET_MEM_REF
>> in ptr_mode and fix it up later.
>
> No, a template is used to get some insight into the supported address
> structure. If there is a mismatch, this approach fails, we can as well
> give the compiler whatever fake template we want.
>

Like this?  This patch restores the previous behavior when REALLY_EXPAND
is false.  I can test it if it is OK.

-- 
H.J.
---
diff --git a/gcc/tree-ssa-address.c b/gcc/tree-ssa-address.c
index c6dced1..4e7b0b5 100644
--- a/gcc/tree-ssa-address.c
+++ b/gcc/tree-ssa-address.c
@@ -221,16 +221,16 @@ addr_for_mem_ref (struct mem_address *addr, addr_space_t a
s,
       if (!templ->ref)
        {
          sym = (addr->symbol ?
-                gen_rtx_SYMBOL_REF (pointer_mode, ggc_strdup ("test_symbol"))
+                gen_rtx_SYMBOL_REF (address_mode, ggc_strdup ("test_symbol"))
                 : NULL_RTX);
          bse = (addr->base ?
-                gen_raw_REG (pointer_mode, LAST_VIRTUAL_REGISTER + 1)
+                gen_raw_REG (address_mode, LAST_VIRTUAL_REGISTER + 1)
                 : NULL_RTX);
          idx = (addr->index ?
-                gen_raw_REG (pointer_mode, LAST_VIRTUAL_REGISTER + 2)
+                gen_raw_REG (address_mode, LAST_VIRTUAL_REGISTER + 2)
                 : NULL_RTX);

-         gen_addr_rtx (pointer_mode, sym, bse, idx,
+         gen_addr_rtx (address_mode, sym, bse, idx,
                        st? const0_rtx : NULL_RTX,
                        off? const0_rtx : NULL_RTX,
                        &templ->ref,

Reply via email to