Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #135492

Re: F>R, FR@ and FR> Float to return stack words

From anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups comp.lang.forth
Subject Re: F>R, FR@ and FR> Float to return stack words
Date 2026-08-30 13:31 +0000
Organization Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID <2026Aug30.153156@mips.complang.tuwien.ac.at> (permalink)
References <20260828000428.00007e53@tin.it> <20260830100637.000013f4@tin.it>

Show all headers | View raw


peter <peter.noreply@tin.it> writes:
>If I do the school book formual I get
>
>: Z*  {f: x y u v :} 
>	x u f* y v f* f- x v f* y u f* f+ ;
>
>
>Which give more compact code
>
>seea Z*
>0x42A730  C4C17B104D00         vmovsd xmm1, qword ptr [r13]
>0x42A736  C4C173594D10         vmulsd xmm1, xmm1, qword ptr [r13+0x10]
>0x42A73C  C4C17B595508         vmulsd xmm2, xmm0, qword ptr [r13+0x8]
>0x42A742  C5F35CCA             vsubsd xmm1, xmm1, xmm2
>0x42A746  C4C17B595510         vmulsd xmm2, xmm0, qword ptr [r13+0x10]
>0x42A74C  C4C17B105D00         vmovsd xmm3, qword ptr [r13]
>0x42A752  C4C163595D08         vmulsd xmm3, xmm3, qword ptr [r13+0x8]
>0x42A758  C5E358DA             vaddsd xmm3, xmm3, xmm2
>0x42A75C  C5E310C3             vmovsd xmm0, xmm3, xmm3
>0x42A760  C4C17B114D10         vmovsd qword ptr [r13+0x10], xmm1
>0x42A766  4D8D6D10             lea r13, [r13+0x10]
>0x42A76A  C3                   ret
>59 bytes, 12 instructions

Cool!

>I tried to measure the execution times. This shows no difference!

Which indicates that the bottleneck of your benchmark is not in the z*
code.

>I had to start with the complex number already on the stack!
>If I put fpi 345e4 inside the loop elapsed time increase with 100 times!

How do you implement FP literals?  One technique is to call FLIT, have
the FP literal behind the call, and let FLIT load from its return
address, then change its return address.  That results in a branch
misprediction (~20 cycles) for every FLIT, but even 2 FLITs with this
technique do not explain 100* slowdown.

- anton
-- 
M. Anton Ertl  http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
     New standard: https://forth-standard.org/
EuroForth 2026 CFP: http://www.euroforth.org/ef26/cfp.html

Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

F>R, FR@ and FR> Float to return stack words peter <peter.noreply@tin.it> - 2026-08-28 00:04 +0200
  Re: F>R, FR@ and FR> Float to return stack words dxf <dxforth@gmail.com> - 2026-08-28 14:44 +1000
  Re: F>R, FR@ and FR> Float to return stack words anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2026-08-28 06:50 +0000
  Re: F>R, FR@ and FR> Float to return stack words marcel hendrix <mhx@iae.nl> - 2026-08-28 19:35 +0200
  Re: F>R, FR@ and FR> Float to return stack words peter <peter.noreply@tin.it> - 2026-08-30 10:06 +0200
    Re: F>R, FR@ and FR> Float to return stack words anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2026-08-30 13:31 +0000
      Re: F>R, FR@ and FR> Float to return stack words peter <peter.noreply@tin.it> - 2026-08-30 15:58 +0200
        Re: F>R, FR@ and FR> Float to return stack words anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2026-08-30 15:12 +0000

csiph-web