 
                 @doInsideBlock test_bb, =>
                         if n.test
-                                cond_truthy = @createCall @ejs_runtime.truthy, [@visit(n.test)], "cond_truthy"
-                                cmp = ir.createICmpEq cond_truthy, consts.false(), "cmpresult"
-                                ir.createCondBr cmp, merge_bb, body_bb
+                                @generateCondBr n.test, body_bb, merge_bb
                         else
                                 ir.createBr body_bb
 

                debug.log -> "operator = '#{n.operator}'"
                result = @createAlloca @currentFunction, types.EjsValue, "result_#{n.operator}"

                left_visited = @visit n.left
                cond_truthy = @createCall @ejs_runtime.truthy, [left_visited], "cond_truthy"

                insertBlock = ir.getInsertBlock()
                insertFunc = insertBlock.parent
        

                if load_result
                        cond_val = @createAlloca @currentFunction, types.EjsValue, "%cond_val"
                
                insertBlock = ir.getInsertBlock()
                insertFunc = insertBlock.parent

