[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LuaJIT2 performance for number crunching
- From: Philippe Lhoste <PhiLho@...>
- Date: Wed, 16 Feb 2011 17:29:56 +0100
On 16/02/2011 17:16, Mike Pall wrote:
Rule #437: Never hoist out constants (if possible)!
Always write constants inline, otherwise they are treated as
variables, which generates worse code. And, yes, even plain Lua is
able to fold 1/5 into a constant. It's important to write these
unambiguously -- FP arithmetic is not associative!
Good to know, but bad programming practice from a formal point of view. :-)
I always recommend to beginners in programming to replace magic numbers with constants,
for readability and consistency. I understand that speed optimizations sometime have to
break these nice rules (like manual loop unrolling and such).
It would be nice, perhaps, if Lua had a way to define true, efficient constants.
(Yes, that's another bag of worm. Perhaps if someone want to comment on my remark, a new
thread should be started...)
--
Philippe Lhoste
-- (near) Paris -- France
-- http://Phi.Lho.free.fr
-- -- -- -- -- -- -- -- -- -- -- -- -- --
- References:
- Re: LuaJIT2 performance for number crunching, Florian Weimer
- Re: LuaJIT2 performance for number crunching, Francesco Abbate
- Re: LuaJIT2 performance for number crunching, Leo Razoumov
- Re: LuaJIT2 performance for number crunching, Francesco Abbate
- Re: LuaJIT2 performance for number crunching, Leo Razoumov
- Re: LuaJIT2 performance for number crunching, Francesco Abbate
- Re: LuaJIT2 performance for number crunching, Leo Razoumov
- Re: LuaJIT2 performance for number crunching, Francesco Abbate
- Re: LuaJIT2 performance for number crunching, T T
- Re: LuaJIT2 performance for number crunching, Daurnimator
- Re: LuaJIT2 performance for number crunching, Mike Pall