On Sat, Jul 9, 2011 at 23:31, H.J. Lu <hjl.to...@gmail.com> wrote:
> On Sat, Jul 9, 2011 at 2:18 PM, Paolo Bonzini <bonz...@gnu.org> wrote:
>> On 07/05/2011 04:27 PM, H.J. Lu wrote:
>>>>
>>>>  diff --git a/gcc/explow.c b/gcc/explow.c
>>>>  index 7387dad..b343bf8 100644
>>>>  --- a/gcc/explow.c
>>>>  +++ b/gcc/explow.c
>>>>  @@ -383,18 +383,13 @@ convert_memory_address_addr_space (enum
>>>> machine_mode to_mode ATTRIBUTE_UNUSED,
>>>>
>>>>      case PLUS:
>>>>      case MULT:
>>>>  -      /* For addition we can safely permute the conversion and addition
>>>>  -        operation if one operand is a constant and converting the
>>>> constant
>>>>  -        does not change it or if one operand is a constant and we are
>>>>  -        using a ptr_extend instruction  (POINTERS_EXTEND_UNSIGNED<  0).
>>>>  -        We can always safely permute them if we are making the address
>>>>  -        narrower.  */
>>>>  +      /* For addition we safely permute the conversion and addition
>>>>  +        operation if one operand is a constant since we can't generate
>>>>  +        new instructions.  We can always safely permute them if we are
>>>>  +        making the address narrower.  */
>>>>        if (GET_MODE_SIZE (to_mode)<  GET_MODE_SIZE (from_mode)
>>>>           || (GET_CODE (x) == PLUS
>>>>  -&&  CONST_INT_P (XEXP (x, 1))
>>>>  -&&  (XEXP (x, 1) == convert_memory_address_addr_space
>>>>  -                                  (to_mode, XEXP (x, 1), as)
>>>>  -                 || POINTERS_EXTEND_UNSIGNED<  0)))
>>>>  +&&  CONST_INT_P (XEXP (x, 1))))
>>>>         return gen_rtx_fmt_ee (GET_CODE (x), to_mode,
>>>>                                convert_memory_address_addr_space
>>>>                                  (to_mode, XEXP (x, 0), as),
>>
>> This does not seem safe to me.
>
> The current code is broken for x32.  See:
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47727
>
> We can't generate any new instructions.  Do you have any suggestions.

By "safe" I mean that the new condition might be too wide and generate
wrong code.  Richard is definitely right in comment 6, generating new
code in simplify-rtx is a no-no (see its usage of
gen_lowpart_no_emit).

Paolo

Reply via email to