This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: simplify_subreg vs gen_rtx_SUBREG vis WORDS_BIG_ENDIAN


> One thing to do is to call simplify_gen_subreg.

As I noted, that may return NULL, which is fatal in the case I'm
referencing.

> But I don't think that will help.  I think this code is simply
> incorrect.  It seems to assume that op_mode is at least as large as
> GET_MODE (xop0), probably because that will be the case on the m68k.

Do we want to just fail that function if we detect the
smaller-than-mode case?  Otherwise, I've been using the below function
to constuct endian-aware subregs, it seems to work.

Of course, none of this answers my original question: what's the
"right" way to form a subreg these days?


static rtx
gen_low_word_subreg (enum machine_mode omode, rtx op, enum machine_mode imode)
{
  int lbyte;

  lbyte = GET_MODE_SIZE (imode) - GET_MODE_SIZE (omode);

  if (! BYTES_BIG_ENDIAN || lbyte < 0)
    return gen_rtx_SUBREG (omode, op, 0);

  return gen_rtx_SUBREG (omode, op, lbyte);
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]