[M3devel] m3cg right shift signed?

Jay K jay.krell at cornell.edu
Tue Jun 9 17:42:59 CEST 2015


Division is among the slowest instructions that operates on integers even on modern hardware.
It is/was frequently completely absent, though maybe those days are past.
6502 and 65816 had no hardware multiply or divide, nor maybe signed shift.
 
 - Jay


 
> Date: Tue, 9 Jun 2015 08:38:29 -0400
> From: hendrik at topoi.pooq.com
> To: m3devel at elegosoft.com
> Subject: Re: [M3devel] m3cg right shift signed?
> 
> On Mon, Jun 08, 2015 at 06:44:07PM -0700, Jay wrote:
> > (Not at propercomputer but sending anyway.)
> > 
> > Is right shift of a signed type meant to be supported and well 
> > defined in the IR? I thought not, and assert so in the C backend. But 
> > it occurs now, from m3front/cg/set_range or such. Maybe change that 
> > to not? Surely unsigned types are adequate here?
> 
> Signed and unsigned right shifts are different on most hardware that 
> supports them.  Signed shifts do sign extension, so that the shifts of 
> negative numbers remain negative.  Unsigned shifts do zero extension.
> 
> There are (once were?) machines where shifts are (were?) faster 
> than division by powers of two.
> 
> Not sure how this relates to whatever in Modula 3 might or might not 
> require them, though.
> 
> -- hendrik
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20150609/eb4d2379/attachment-0002.html>


More information about the M3devel mailing list