Re: LW compiler optimizations
Martin Simmons <[email protected]>
| Newsgroups | gmane.lisp.lispworks.general |
|---|---|
| Message-ID | <[email protected]> |
>>>>> On Sat, 11 Jan 2025 14:43:32 +0100, Yuri Davidovsky (as work at disclosure dot ie) said: > > > On 11 Jan 2025, at 14:18, Tim Bradshaw <[email protected]> wrote: > > > > So for instance a common trick is to use tag bits of all zeros to encode fixnums: the word then contains the fixnum shifted right by the number of tag bits, and then zeros. This makes fixnum addition just machine addition, while for multiplication you have to shift things left first. > > > > For a single-float you have the whole lower half word free, of course. > > > So it appears, not matter how you spin it, you always have to do something with incoming arguments in lisp? Meaning, it is never possible to do it the way you do it in C, just take two args, put them into the CPU registers, do a calculation, read the result back form the register and be done? > > For example, if single floats are represented as immediate objects, we have to: > > 1. Check the tag bits to make sure what type we have coming in. > 2. If that appears to be a single float, we need to extract it from the argument. > 3. Do an operation on it (add, subtract, multiply, etc). > 4. Wrap it back into a 64 bit immediate object. > 5. Return it. > > And looking at the sequence of actions, would that be that much faster compared to reading a value from the heap, which likely will be in the CPU cache already? Step 4 has to allocate an object for a type that is not immediate, so that can make the immediate types faster. It all depends on the ratio of extracting compared to wrapping. Also, step 1 for a heap allocated object might involve reading some type information from heap as well as checking the tag bits. -- Martin Simmons LispWorks Ltd http://www.lispworks.com/ _______________________________________________ Lisp Hug - the mailing list for LispWorks users [email protected] http://www.lispworks.com/support/lisp-hug.html