On 2010-10-02, at 12:06 PM, chevalma@iro.umontreal.ca wrote:
I wrote this bit of code instead:
var trueLabel = tltor.asm.labelObj();
tltor.asm. mov($(1), dest). jl(trueLabel). mov($(0), dest). label(trueLabel)
Jumps are to be avoided. They cause branch prediction problems, and in this case they take more code memory. I agree that using a memory load is also to be avoided in general. So the conditional move with a register is a better solution. Note that we know the content of the context register and we also know it is non-zero. So we can use it as a non-false value, and 0 as the false value. The code would then be:
mov $0, dest_reg cmovl ctx_reg, dest_reg
and the conditional jump would test for non-zero:
test dest_reg, dest_reg jne true_branch
Marc