Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site myrias.UUCP Path: utzoo!utcsri!ubc-vision!alberta!myrias!cg From: cg@myrias.UUCP (Chris Gray) Newsgroups: net.lang.c Subject: Re: Tail recursion Message-ID: <241@myrias.UUCP> Date: Wed, 16-Apr-86 11:43:24 EST Article-I.D.: myrias.241 Posted: Wed Apr 16 11:43:24 1986 Date-Received: Wed, 16-Apr-86 14:43:41 EST References: <2516@utcsri.UUCP> <708@bentley.UUCP> <2563@utcsri.UUCP> Organization: Myrias Research, Edmonton Lines: 18 When I was playing around with a compiler (not a C compiler) for CP/M-80 I included the following peephole optimization: call x => jmp x ret Of course it was only done if the call wasn't preceded by a PUSH. Unfortunately, some of the built-in constructs which required run-time support had arguments that were pushed onto the stack at some indeterminate time in the past. I put in some kludges to handle them (flushing the peephole after the call), but there were still problems. In the end the amount of kludging to get it right outweighed the benefits, so I just ripped out the optimization. This is a much simpler case than recognizing tail recursion, but it does illustrate some of the things compiler writers will try to do. Chris Gray (ihnp4!alberta!myrias!cg)