On Tue, Jul 19, 2011 at 10:46 AM, Richard Guenther <richard.guent...@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. I have investigated other Pmode != ptr_mode targets, and none of them check the mode of a register in TARGET_LEGITIMATE_ADDRESS_P (or equivalent GO_IF_LEGITIMATE_ADDRESS). All it matters is only if there is a register and regno of the register. Attached patch simply removes these two checks, as it seems they are not needed. This also follows how other Pmode != ptr_mode targets. 2011-07-19 Uros Bizjak <ubiz...@gmail.com> PR target/49780 * config/i386/i386.c (ix86_legitimate_address_p): Remove checks that base and index registers are in Pmode. Patch was bootstrapped and regression tested on x86_64-pc-linux-gnu {,-m32}. Can you please re-test it on x32? BTW: I still think that template should return the same address structure as expansion, but this won't crash the compiler anymore. Uros.
Index: config/i386/i386.c =================================================================== --- config/i386/i386.c (revision 176433) +++ config/i386/i386.c (working copy) @@ -11653,10 +11653,6 @@ ix86_legitimate_address_p (enum machine_ /* Base is not a register. */ return false; - if (GET_MODE (base) != Pmode) - /* Base is not in Pmode. */ - return false; - if ((strict && ! REG_OK_FOR_BASE_STRICT_P (reg)) || (! strict && ! REG_OK_FOR_BASE_NONSTRICT_P (reg))) /* Base is not valid. */ @@ -11682,10 +11678,6 @@ ix86_legitimate_address_p (enum machine_ /* Index is not a register. */ return false; - if (GET_MODE (index) != Pmode) - /* Index is not in Pmode. */ - return false; - if ((strict && ! REG_OK_FOR_INDEX_STRICT_P (reg)) || (! strict && ! REG_OK_FOR_INDEX_NONSTRICT_P (reg))) /* Index is not valid. */