From patchwork Sat Apr 2 05:34:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: PATCH: copy_addr_to_reg: Convert to Pmode if needed From: "H.J. Lu" X-Patchwork-Id: 89426 Message-Id: To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Date: Fri, 1 Apr 2011 22:34:18 -0700 On Mon, Mar 21, 2011 at 9:05 AM, Richard Sandiford wrote: > "H.J. Lu" 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. 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 PR target/48084 + * config/i386/i386.c (ix86_expand_builtin): Call + convert_memory_address. + +2011-03-21 H.J. Lu + + PR target/48084 * explow.c (copy_addr_to_reg): Don't convert to Pmode here. 2011-03-17 H.J. Lu 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;