Patchwork PATCH: copy_addr_to_reg: Convert to Pmode if needed

login
register
mail settings
Submitter H.J. Lu
Date April 2, 2011, 5:34 a.m.
Message ID <BANLkTi=xGeubckC5tE9jrWgecDNzV97jqQ@mail.gmail.com>
Download mbox | patch
Permalink /patch/89426/
State New
Headers show

Comments

H.J. Lu - April 2, 2011, 5:34 a.m.
On Mon, Mar 21, 2011 at 9:05 AM, Richard Sandiford
<richard.sandiford@linaro.org> wrote:
> "H.J. Lu" <hongjiu.lu@intel.com> writes:
>> diff --git a/gcc/explow.c b/gcc/explow.c
>> index 460af1f..9b3c082 100644
>> --- a/gcc/explow.c
>> +++ b/gcc/explow.c
>> @@ -611,6 +611,8 @@ copy_to_reg (rtx x)
>>  rtx
>>  copy_addr_to_reg (rtx x)
>>  {
>> +  if (GET_MODE (x) != VOIDmode && GET_MODE (x) != Pmode)
>> +    x = convert_to_mode (Pmode, x, 1);
>>    return copy_to_mode_reg (Pmode, x);
>>  }
>
> I think you need to say why the conversion should be done here
> rather than in the caller.
>
> Regardless of that, though: I think this should be convert_memory_address
> rather than convert_to_mode.  Paasing 1 is wrong, because pointers are
> signed on some targets.
>
> Richard
>

I checked in this patch instead.

Patch

diff --git a/gcc/ChangeLog.x32 b/gcc/ChangeLog.x32
index 86e4425..fa9d384 100644
--- a/gcc/ChangeLog.x32
+++ b/gcc/ChangeLog.x32
@@ -1,6 +1,12 @@ 
 2011-03-21  H.J. Lu  <hongjiu.lu@intel.com>

 	PR target/48084
+	* config/i386/i386.c (ix86_expand_builtin): Call
+	convert_memory_address.
+
+2011-03-21  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR target/48084
 	* explow.c (copy_addr_to_reg): Don't convert to Pmode here.

 2011-03-17  H.J. Lu  <hongjiu.lu@intel.com>
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 73ce73a..4ac335f 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -27790,7 +27790,10 @@  rdrand_step:
       arg0 = CALL_EXPR_ARG (exp, 0);
       op1 = expand_normal (arg0);
       if (!address_operand (op1, VOIDmode))
-	op1 = copy_addr_to_reg (op1);
+	{
+	  op1 = convert_memory_address (Pmode, op1);
+	  op1 = copy_addr_to_reg (op1);
+	}
       emit_move_insn (gen_rtx_MEM (mode0, op1), op0);
       return target;