[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LuaJIT - Trace aborted again
- From: Benjamin Segovia <segovia.benjamin@...>
- Date: Wed, 20 Jul 2011 16:45:06 +0000
Hmmm.
This is not really a if/then/else construct I need but really a
forward jump. Basically, it is a SIMD scatter/gather machine. Some
instructions inactivate lanes from the SIMD vector. In a block, if
your instruction currently deactivates all lanes, then you exit the
block, reset the mask you got before potentially modified by the
computations in the previous block. Then you check the current mask.
If it is still zero, then you exit the block ...
Maybe to be more precise: the biggest issue basically is that I need
to emulate "continue" and "breaks" because the machine can execute
"continue" and "break" instructions natively.
Actually "continue" instructions are really the big problem, since
there is no continue in lua.
Right now, I used a two-nested-loop hack to handle continue:
repeat
local a_break_was_used_for_a_continue = false
repeat
-- .... "CONTINUE" instruction generates ->
a_break_was_used_for_a_continue = true
break
-- end of continue
-- .... "BREAK" instruction generates ->
a_break_was_used_for_a_continue = false
break
-- end of break
until true -- <- this is fake loop to early branch out (used for
breaks and continues)
if not a_break_was_used_for_a_continue then beak end
until false -- <- this is a real loop. Youhou!
As you can see, the technique is easy to implement since regardless
where I am in the nested branches (like for example, deeply nested in
IFs), I can early out.
I am afraid that using only if/then/else to mask the code may be a
more serious code transform. Something similar to unstructured
branches to structures branches transform... ie not that easy to do
:-)
I will try other things today.
Thank you very much for your help
Ben
On Wed, Jul 20, 2011 at 2:52 PM, Mike Pall <mikelu-1107@mike.de> wrote:
> David Kastrup wrote:
>> Mike Pall <mikelu-1107@mike.de> writes:
>> > I do not see how that's different from doing it with a while loop.
>> > You'd need to nest them and close them with 'end' as well.
>>
>> No, you need just a single loop at a time that can deal with dozens of
>> "break" in there.
>
> Sure. But is that a realistic use case? If the VLIW code is
> generated from typical code in a high-level language, I doubt
> you'd see more than a handful of these. Nesting (say) 100
> if/then/else is no problem.
>
> --Mike
>
>