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: help for arm avr bfin cris frv h8300 m68k mcore mmix pdp11 rs6000 sh vax


> The Blackfin does not truncate shift counts.  The documentation
> specifies that e.g. for "Dx >>= Dy" instructions, shift counts greater
> than 31 produce a result of zero.  Other shift instructions use a sign
> extended part of the shift count to shift either left or right.  "I
> don't know" is probably the best answer we can give the compiler.

In my plan, the truncation of shifts is used to canonicalize RTL created
with out of range shift counts.  This is useful because such out of
range RTL can appear because of unrolling or inlining.  Then the answer
should be based on this: would a "typical" C programmer expect a left
and a right shift from this:

int f(int a)
{
  return 0x4000 << a;
}

int x, y;
int main()
{
  x = f(1);
  y = f(-1);
}

If the C program above can be reasonably considered undefined with
Blackfin, saying "shifts are not truncated" is okay.  This is because
the variable left/right shifts can still be described as rtl like

  (set A (if_then_else (lt B (const_int 0))
                       (lshiftrt A (minus (const_int 0) B))
                       (lshift A B)))

so that the actual arguments are LSHIFT/LSHIFTRT are positive.

Paolo


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