Hi, TARGET_MEM_REF only works on ptr_mode. This patch allows 32bit address in x32 mode. OK for trunk?
Thanks. H.J. --- 2011-07-18 H.J. Lu <hongjiu...@intel.com> * config/i386/i386.c (ix86_legitimate_address_p): Support 32bit address in x32 mode. diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 04cb07d..c852719 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -11522,6 +11761,7 @@ ix86_legitimate_address_p (enum machine_mode mode ATTRIBUTE_UNUSED, struct ix86_address parts; rtx base, index, disp; HOST_WIDE_INT scale; + enum machine_mode base_mode; if (ix86_decompose_address (addr, &parts) <= 0) /* Decomposition failed. */ @@ -11553,8 +11793,11 @@ ix86_legitimate_address_p (enum machine_mode mode ATTRIBUTE_UNUSED, /* Base is not a register. */ return false; - if (GET_MODE (base) != Pmode) - /* Base is not in Pmode. */ + base_mode = GET_MODE (base); + if (base_mode != Pmode + && !(TARGET_X32 + && base_mode == ptr_mode)) + /* Base is not in Pmode nor ptr_mode. */ return false; if ((strict && ! REG_OK_FOR_BASE_STRICT_P (reg)) @@ -11562,6 +11805,8 @@ ix86_legitimate_address_p (enum machine_mode mode ATTRIBUTE_UNUSED, /* Base is not valid. */ return false; } + else + base_mode = VOIDmode; /* Validate index register. @@ -11570,6 +11815,7 @@ ix86_legitimate_address_p (enum machine_mode mode ATTRIBUTE_UNUSED, if (index) { rtx reg; + enum machine_mode index_mode; if (REG_P (index)) reg = index; @@ -11582,8 +11828,13 @@ ix86_legitimate_address_p (enum machine_mode mode ATTRIBUTE_UNUSED, /* Index is not a register. */ return false; - if (GET_MODE (index) != Pmode) - /* Index is not in Pmode. */ + index_mode = GET_MODE (index); + if ((base_mode != VOIDmode + && base_mode != index_mode) + || (index_mode != Pmode + && !(TARGET_X32 + && index_mode == ptr_mode))) + /* Index is not in Pmode nor ptr_mode. */ return false; if ((strict && ! REG_OK_FOR_INDEX_STRICT_P (reg))