From: Jérémie Astor Date: Tue, 16 Nov 2021 23:00:21 +0000 (+0100) Subject: :art: Use deep equality in memoize X-Git-Tag: nightly~406 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=639f5d6d16f9a644d8f1b0da8c974d7e92c0e3cf;p=gwion.git :art: Use deep equality in memoize --- diff --git a/src/emit/emit.c b/src/emit/emit.c index ccb7e4d1..e0acdbad 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -1560,13 +1560,40 @@ ANN static Instr me_push(const MemoizeEmitter *me, const m_uint sz) { static m_bool me_cmp(MemoizeEmitter *me, const Arg_List arg) { const Emitter emit = me->emit; - const Symbol sym = insert_symbol("=="); - struct Exp_ exp = {}; + const Symbol sym = insert_symbol("?="); + struct Exp_ lhs = { + .exp_type = ae_exp_primary, + .type = arg->type, + .pos = arg->td->pos, + .d = { + .prim = { .prim_type = ae_prim_id } + } + }; + struct Exp_ rhs = { + .exp_type = ae_exp_primary, + .type = me->emit->gwion->type[et_bool], + .pos = arg->td->pos, + .d = { + .prim = { .prim_type = ae_prim_id } + } + }; + struct Exp_ bin = { + .exp_type = ae_exp_binary, + .type = arg->type, + .pos = arg->td->pos, + .d = { + .exp_binary = { + .lhs = &lhs, + .op = sym, + .rhs = &rhs + } + } + }; struct Op_Import opi = {.op = sym, .lhs = arg->type, .rhs = arg->type, .pos = me->fdef->base->pos, - .data = (uintptr_t)&exp.d}; + .data = (uintptr_t)&bin.d}; CHECK_BB(op_emit(emit, &opi)); const Instr instr = emit_add_instr(emit, BranchEqInt); vector_add(&me->branch, (vtype)instr);