home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.vms
- Path: sparky!uunet!eco.twg.com!eco.twg.com!reece
- From: reece@eco.twg.com (Reece R. Pollack)
- Subject: Re: VAXC divide problems (V3.2)
- Message-ID: <1993Jan22.231842.4799@eco.twg.com>
- Lines: 45
- Sender: reece@crash.eco.twg.com (Reece R. Pollack)
- Nntp-Posting-Host: eco.twg.com
- Reply-To: reece@eco.twg.com
- Organization: The Wollongong Group (East Coast Operations)
- References: <1993Jan22.060311.5226@cs.rit.edu>
- Date: Fri, 22 Jan 93 23:18:42 GMT
- Lines: 45
-
-
- In article <1993Jan22.060311.5226@cs.rit.edu>, whd0675@cs.rit.edu (Walter H Dick, III) writes:
- |>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
-
- 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
-
- Don't ask me why it allocated space on the stack without using it, but
- the divide code certainly matches what the customer ordered. If course,
- I've preferred if it generated:
-
- .entry func,^m<>
- addl3 #511,4(ap),r0
- ashl #-9,r0,r0
- ret
-
- Maybe there's something special about your program that makes it more
- efficient to execute the 10 instruction rather than a divide?
-
- --
- Reece R. Pollack
- Senior Software Engineer
- The Wollongong Group, Inc.
-