Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!aioe.org!.POSTED!not-for-mail From: "Rod Pemberton" Newsgroups: comp.lang.forth Subject: Re: Floating Point : To Stack or Not To Stack Date: Sun, 27 Oct 2013 03:01:42 -0400 Organization: Aioe.org NNTP Server Lines: 35 Message-ID: References: <7xbo2co681.fsf@ruckus.brouhaha.com> <2013Oct26.114518@mips.complang.tuwien.ac.at> <526ba7c6$0$26897$e4fe514c@dreader37.news.xs4all.nl> NNTP-Posting-Host: CNsg4fVcCsvs3UaOgZtQCw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/12.16 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.forth:26702 On Sat, 26 Oct 2013 09:09:45 -0400, wrote: > On Saturday, October 26, 2013 1:30:14 PM UTC+2, Albert van der Horst > wrote: > [..] >> The optimising compiler agrees with me. The first translate >> to primitive operations and a jump. The second to two jumps. > > ... which can have substantial effects: > > FORTH> : t1 ?dup if 1 + endif ; ok > FORTH> : t2 dup if 1 + else drop endif ; ok > FORTH> 1000000000 value #t > : bm cr timer-reset 1 #t 0 do t1 loop . .elapsed > cr timer-reset 1 #t 0 do t2 loop . .elapsed ; ok > FORTH> bm > 1000000001 3.767 seconds elapsed. > 1000000001 1.513 seconds elapsed. ok > In this context, is ?DUP a "primitive" or defined as "DUP IF DUP THEN" or some other sequence? If ?DUP is a sequence, like "DUP IF DUP THEN", then it should be fairly obvious that it results in longer, more complicated code, if there is no optimization. Is this for an optimizing Forth? If so, I'd expect it to result in the same optimized code for both definitions: t1 and t2, i.e., their times should be the same. Rod Pemberton