home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / os / vms / 21790 < prev    next >
Encoding:
Text File  |  1993-01-23  |  1.4 KB  |  60 lines

  1. Newsgroups: comp.os.vms
  2. Path: sparky!uunet!eco.twg.com!eco.twg.com!reece
  3. From: reece@eco.twg.com (Reece R. Pollack)
  4. Subject: Re: VAXC divide problems (V3.2)
  5. Message-ID: <1993Jan22.231842.4799@eco.twg.com>
  6. Lines: 45
  7. Sender: reece@crash.eco.twg.com (Reece R. Pollack)
  8. Nntp-Posting-Host: eco.twg.com
  9. Reply-To: reece@eco.twg.com
  10. Organization: The Wollongong Group (East Coast Operations)
  11. References:  <1993Jan22.060311.5226@cs.rit.edu>
  12. Date: Fri, 22 Jan 93 23:18:42 GMT
  13. Lines: 45
  14.  
  15.  
  16. In article <1993Jan22.060311.5226@cs.rit.edu>, whd0675@cs.rit.edu (Walter H Dick, III) writes:
  17. |>A statement in VAXC such as:
  18. |>
  19. |>   i = (x + 511) / 512;
  20. |>
  21. |>generates ten or so instructions.  Is there anyway to get it to generate:
  22. |>
  23. |>   ADDL3  #511,x,R0
  24. |>   DIVL3  R0,#512,i
  25.  
  26. That's funny, when I compiled this function:
  27.  
  28. func( int x )
  29. {
  30.     int         i;
  31.  
  32.     i = (x + 511) / 512;
  33.     return( i );
  34. }
  35.  
  36. VAX C V3.2-044 generated this code:
  37.  
  38.     .entry    func,^m<>
  39.     subl2    #4,sp
  40.     addl3    #511,4(ap),r0
  41.     divl2    #512,r0
  42.     ret
  43.  
  44. Don't ask me why it allocated space on the stack without using it, but
  45. the divide code certainly matches what the customer ordered. If course,
  46. I've preferred if it generated:
  47.  
  48.     .entry    func,^m<>
  49.     addl3    #511,4(ap),r0
  50.     ashl    #-9,r0,r0
  51.     ret
  52.  
  53. Maybe there's something special about your program that makes it more
  54. efficient to execute the 10 instruction rather than a divide?
  55.  
  56. --
  57. Reece R. Pollack
  58. Senior Software Engineer
  59. The Wollongong Group, Inc.
  60.