home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!elroy.jpl.nasa.gov!ames!agate!ucbvax!EQL.CALTECH.EDU!rankin
- From: rankin@EQL.CALTECH.EDU (Pat Rankin)
- Newsgroups: comp.os.vms
- Subject: Re: VAXC divide problems (V3.2)
- Message-ID: <930125173835.21c0f8a0@EQL.Caltech.Edu>
- Date: 26 Jan 93 01:41:20 GMT
- Sender: daemon@ucbvax.BERKELEY.EDU
- Distribution: world
- Organization: The Internet
- Lines: 41
-
- |>A statement in VAXC such as:
- |> i = (x + 511) / 512;
- |>generates ten or so instructions. Is there anyway to get it to generate:
- |> ADDL3 #511,x,R0
- |> DIVL3 R0,#512,i
-
- Then one of several posters who have refuted this...
-
- > That's funny, when I compiled this function:
- >
- func( int x )
- {
- int i;
- i = (x + 511) / 512;
- return( i );
- }
- >
- > VAX C V3.2-044 generated this code:
- > .entry func,^m<>
- > subl2 #4,sp
- > addl3 #511,4(ap),r0
- > divl2 #512,r0
- > ret
-
- Even CC/NOOPTIMIZE generates only three instructions for the
- division (3rd instruction updates `i' on the stack instead of using
- a register for it). "Ten or so" seems to be some sort of hallucination.
- Even VAX C V2.2--which is many years old by now--generates the same code
- (once the function is changed to use "old style" argument declaration :-).
-
- > Don't ask me why it allocated space on the stack without using it,
-
- That makes room for a "hidden automatic variable" at the top of the
- stack for use by VAXC$ESTABLISH(). The compiler just allocates that
- automatically--so do recent releases of GNU C--rather than attempting
- to determine whether VAXC$ESTABLISH is actually called. VAXC$ESTABLISH
- cannot safely be used when the compiler doesn't do this; that's why it's
- documented as only being supported when used from VAX C.
-
- Pat Rankin, rankin@eql.caltech.edu
-
-