public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Dave Korn" <dk@artimi.com>
To: "'Peter Barada'" <peter@the-baradas.com>, <aph@redhat.com>
Cc: <dalej@apple.com>, <gcc@gcc.gnu.org>, <nathan@codesourcery.com>
Subject: RE: warning: right shift count >= width of type
Date: Mon, 29 Nov 2004 18:53:00 -0000	[thread overview]
Message-ID: <NUTMEGdu189BiyQ2UP2000001c6@NUTMEG.CAM.ARTIMI.COM> (raw)
In-Reply-To: <20041129180903.5C5E79842C@baradas.org>

> -----Original Message-----
> From: Peter Barada  
> Sent: 29 November 2004 18:09

> > > ISTM reasonable that the result of a right-shift by 32 bits could
> > > be assumed to be the same thing you get if you 
> right-shift by 1 bit
> > > 32 times....
> >
> >The chip designers don't agree.
> 
> They *definitely* don't agree.  Most shift hardware is designed as a
> barrel shifter which is a large combinational logic block 
> that takes the
> n-bits of the shift count and using them determine what each bit of
> the result is supposed to be.  This allows a shift that takes only one
> clock, wheter the shift is arithmetic or logical, right or left, and a
> shift count from 0 up to the number of bits in the register-1.
> 
> Any shift count outside of that range is considered "undefined".

  No, I think it's more accurate to say that any shift count outside that
range is *unimplemented*.  "Undefined" is a concept from the C language
standard; mathematically, the operation is well defined, and in a practical
physical implementation, the operation is either "implemented" or
"unimplemented", but either way can hardly fail to be "defined", owing to
the deterministic nature of hardware implementations.
 
> n 1-bit shifts is equivient to 1 n-bit shift only if n is less than
> the size of the register in bits, at least for a hardware
> implementation described above.

  Similarly, I would say that 1 n-bit shift simply cannot be expressed on
such hardware, and it is meaningless to compare the outcome of a series of
operations that exist with some entirely hypothetical outcome of an
operation that simply does *not* exist.


    cheers, 
      DaveK
-- 
Can't think of a witty .sigline today....

  reply	other threads:[~2004-11-29 18:35 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-29 16:30 Dave Korn
2004-11-29 16:33 ` Nathan Sidwell
2004-11-29 17:01 ` Andrew Haley
2004-11-29 17:12 ` Dale Johannesen
2004-11-29 17:14   ` Dave Korn
2004-11-29 17:26     ` Andrew Haley
2004-11-29 18:29       ` Peter Barada
2004-11-29 18:53         ` Dave Korn [this message]
2004-11-29 18:52       ` Dave Korn
2004-11-29 19:09         ` Andrew Haley
2004-11-29 19:17           ` Dale Johannesen
2004-11-29 19:54             ` Dave Korn
2004-11-29 17:38     ` Chris Jefferson
2004-11-29 18:46       ` Dave Korn
2004-11-29 19:19         ` Chris Jefferson
2004-11-29 19:46           ` Dave Korn
2004-11-29 23:49 Paul Schlie
2004-11-30  1:50 ` Andreas Schwab
2004-11-30  4:23 Paul Schlie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=NUTMEGdu189BiyQ2UP2000001c6@NUTMEG.CAM.ARTIMI.COM \
    --to=dk@artimi.com \
    --cc=aph@redhat.com \
    --cc=dalej@apple.com \
    --cc=gcc@gcc.gnu.org \
    --cc=nathan@codesourcery.com \
    --cc=peter@the-baradas.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).