Unexpected evaluation in conditional branch

Dibyendu Majumdar mobile@majumdar.org.uk
Thu Jan 1 00:00:00 GMT 2015


On 27 June 2015 at 20:29, Dibyendu Majumdar <mobile@majumdar.org.uk> wrote:
> Hi Dave,
>
> I have scenario where the conditional branch is evaluating the result
> of a comparison - one of the operands of the comparison is a function
> call. The generated code appears to evaluate the comparison twice -
> once for the true branch and once for the false branch - which is not
> what I am expecting. I can of course store the result of the
> comparison in a local variable and then perform conditional branch on
> the variable but I wanted to check whether this behaviour is as
> expected.
>

Sadly even after assigning to a local variable the code I am getting
is evaluating the expression twice. Now I get:

  L->top = &base[(int)2];
  condition_0_4 = luaD_precall (L, &base[(int)0], (int)0) == (int)0;
  if (condition_0_4) goto OP_CALL_if_lua_function_2_1; else goto
OP_CALL_else_lua_function_2_2;

OP_CALL_if_lua_function_2_1:
  (void)luaV_execute (L);
  goto OP_CALL_done_2_3;

OP_CALL_else_lua_function_2_2:
  condition_0_6 = luaD_precall (L, &base[(int)0], (int)0) == (int)1;
  if (condition_0_6) goto OP_CALL_if_C_function_2_5; else goto OP_CALL_done_2_3;



More information about the Jit mailing list