home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / os / mswindo / programm / misc / 5251 < prev    next >
Encoding:
Text File  |  1993-01-21  |  2.1 KB  |  46 lines

  1. Newsgroups: comp.os.ms-windows.programmer.misc
  2. Path: sparky!uunet!munnari.oz.au!metro!usage!news
  3. From: troy@cbme.unsw.EDU.AU (Troy Rollo)
  4. Subject: Re: Another bug in Borland C++
  5. Message-ID: <1993Jan21.231507.28729@usage.csd.unsw.OZ.AU>
  6. Sender: news@usage.csd.unsw.OZ.AU
  7. Nntp-Posting-Host: plod.cbme.unsw.edu.au
  8. Organization: University of New South Wales
  9. References: <1993Jan21.002358.25085@ccu1.aukuni.ac.nz>
  10. Date: Thu, 21 Jan 1993 23:15:07 GMT
  11. Lines: 33
  12.  
  13. From article <1993Jan21.002358.25085@ccu1.aukuni.ac.nz>, by tantrum@ccu1.aukuni.ac.nz (Michael Tantrum):
  14. >    Here's a trick for young fools...  I've found a bug in the optimizer.  I
  15. >    hope this isn't old news.
  16.  .
  17. >    I have all the optimizations turned on, including global common
  18. >    subexpression elimination.  The code is fine until the last two
  19. >    statements.  Then, the compiler generates:
  20. >      ...   /* code to compute array address */
  21. >    mov ax,[bp-0c]    /* i.e. the value of i */
  22. >    inc ax            /* now ax = i + 1 */
  23. >    mov es:[bx],ax    /* put the result into the array */
  24. >    cmp ax,limit
  25. >    jl startOfLoop
  26. >    ... So the result is, the variable is never stored back!  i is stuck at
  27. >    zero, never incremented.  Bummer!  Looks like the live range analysis
  28. >    goofed.
  29.  
  30. I've seen this before, and this is (partly) while one of the very few rules
  31. I have for coding around here applies to what optimisations are to be used.
  32. The permitted ones are limited to the most basic optimisations.
  33.  
  34. In the end, if the code is well written, the optimisations will only help
  35. by about 5%. Much better optimisation can be done by improving the code.
  36. At a 5% speed improvement, the risk of optimiser induced bugs creeping
  37. in (including some subtle ones that might escape QA) is far too high.
  38. --
  39. _______________________________________________________________________________
  40. troy@cbme.unsw.EDU.AU          Overworked, overcommited and always multitasking.
  41. Opinions expressed are not those of the CBME or UNSW, but are my opinions only.
  42. You are free to adopt them.   I suggest you adopt them.    You will adopt them!
  43.