lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tue, Feb 22, 2011 at 7:54 PM, Mike Pall <mikelu-1102@mike.de> wrote:

> Well, storing and reloading from FFI types only to force a
> truncation is almost never a win.

I had a nagging suspicion about this, especially at that "This by
itself was already pretty fast with LuaJIT" phase. An apparent victory
with ctypes and I went stumbling down the wrong road. Looking for
nails to pound with my shiny new hammer. :)

> I've cleaned up the 2D case and improved it a bit. It's about 50%
> faster now. See the attached file.

Many thanks! And obviously these improvements lend themselves to the
3D case as well.

I'm kicking myself for missing that Perms12 lookup table. :)

> Umm, this doesn't make sense:
>  if jit.status("be") then ...
> You probably meant ffi.abi("be")?

.....sigh. Yep!

> Also, type punning through a union violates the strict aliasing
> rules. Depends a lot on the surrounding context whether it does
> what you intended it to do (usually it doesn't).

Good to know, and it was indeed making me a bit uneasy.

> As you can see from the code, there's a simpler (and portable) way
> to do it: local a = rshift(floor(y0 - x0), 31)
>
> --Mike
>

Good to know as well. I'm going to bludgeon myself unconscious with
all the self-kicking. :(

Also, since I brought up "register coalescing too complex", what will
that account for when it's no longer NYI? Or considered otherwise, are
there specific constructs to avoid now, if it can be helped?

Thanks again!

- Steve