Article View: comp.os.linux.misc
Article #56Re: Two things, RedHat + Linux efficiency
From: Kazimir Kylheku
Date: Thu, 14 Mar 1996 17:35
Date: Thu, 14 Mar 1996 17:35
26 lines
1744 bytes
1744 bytes
In article <4i5lev$fd3@agate.berkeley.edu>, Nick Kralevich <nickkral@america.CS.Berkeley.EDU> wrote: >In article <4lFXuqq00aw=M=iUNp@andrew.cmu.edu>, >Nicholas P Konidaris <npk+@andrew.cmu.edu> wrote: >>Ok, these are two totally unrelated questions/comments.. I was coding >>around on my box, and wanted to see the speed difference (my CS prof >>told me that x++ is faster than x = x + 1) So, I write code that looks >>like: The ``CS'' prof obviously doesn't understand the construction of programming languages. The computation, and data flow is identical in either case. In the intermediate representation generated by the compiler's syntactic and semantic analysis, you may not recognize the difference between x++ and x = x + 1, or x += 1 anymore. If a three-operand abstract code is used, all three may look like: t3 := t3 + 1 Where t3 is some sequentially generated temporary value (which will be subject to register allocation later). When machine-specific optimization is done, an addition of 1 may be converted into some quick form (such as ADDQ on a 680x0 which can add a three-bit value 8,1-7, stored inside the opcode, to an operand) or an increment instruction. The x++ idiom is faster all right. Faster to type... --
Technical Details
Message-ID:
<4i9ldoINNd88@keats.ugrad.cs.ubc.ca>Path:
arc1-ca.pugleaf.net!keats.ugrad.cs.ubc.ca!not-for-mailReferences:
<4lFXuqq00aw=M=iUNp@andrew.cmu.edu> <4i5lev$fd3@agate.berkeley.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!keats.ugrad.cs.ubc.ca!not-for-mail From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) Newsgroups: comp.os.linux.misc,comp.lang.c Subject: Re: Two things, RedHat + Linux efficiency Date: 14 Mar 1996 09:35:52 -0800 Organization: Computer Science, University of B.C., Vancouver, B.C., Canada Message-ID: <4i9ldoINNd88@keats.ugrad.cs.ubc.ca> References: <4lFXuqq00aw=M=iUNp@andrew.cmu.edu> <4i5lev$fd3@agate.berkeley.edu> NNTP-Posting-Host: keats.ugrad.cs.ubc.ca