From fee84965c185e38ec4353c8b2561378f3d61aa3b Mon Sep 17 00:00:00 2001 From: Spoike Date: Tue, 18 Sep 2018 04:35:33 +0000 Subject: [PATCH] Fix a stupid logic bug that was dropping stores by folding double nots. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5307 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/qclib/qcc_pr_comp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/engine/qclib/qcc_pr_comp.c b/engine/qclib/qcc_pr_comp.c index 404b89502..0cb69d2d7 100644 --- a/engine/qclib/qcc_pr_comp.c +++ b/engine/qclib/qcc_pr_comp.c @@ -2961,7 +2961,7 @@ QCC_sref_t QCC_PR_StatementFlags ( QCC_opcode_t *op, QCC_sref_t var_a, QCC_sref_ { //optimise based on last statement. if (op - pr_opcodes == OP_IFNOT_I) { - if (opt_shortenifnots && var_a.cast && var_a.sym->refcount == 1 && (statements[numstatements-1].op == OP_NOT_F || statements[numstatements-1].op == OP_NOT_FNC || statements[numstatements-1].op == OP_NOT_ENT)) + if (opt_shortenifnots && var_a.cast && var_a.sym->temp && var_a.sym->refcount == 1 && (statements[numstatements-1].op == OP_NOT_F || statements[numstatements-1].op == OP_NOT_FNC || statements[numstatements-1].op == OP_NOT_ENT)) { if (statements[numstatements-1].c.sym == var_a.sym && statements[numstatements-1].c.ofs == var_a.ofs) { @@ -2980,7 +2980,7 @@ QCC_sref_t QCC_PR_StatementFlags ( QCC_opcode_t *op, QCC_sref_t var_a, QCC_sref_ } else if (op - pr_opcodes == OP_IFNOT_F) { - if (opt_shortenifnots && var_a.cast && var_a.sym->refcount == 1 && statements[numstatements-1].op == OP_NOT_F) + if (opt_shortenifnots && var_a.cast && var_a.sym->temp && var_a.sym->refcount == 1 && statements[numstatements-1].op == OP_NOT_F) { if (statements[numstatements-1].c.sym == var_a.sym && statements[numstatements-1].c.ofs == var_a.ofs) { @@ -2996,7 +2996,7 @@ QCC_sref_t QCC_PR_StatementFlags ( QCC_opcode_t *op, QCC_sref_t var_a, QCC_sref_ } else if (op - pr_opcodes == OP_IFNOT_S) { - if (opt_shortenifnots && var_a.cast && statements[numstatements-1].op == OP_NOT_S) + if (opt_shortenifnots && var_a.cast && var_a.sym->temp && var_a.sym->refcount == 1 && statements[numstatements-1].op == OP_NOT_S) { if (statements[numstatements-1].c.sym == var_a.sym && statements[numstatements-1].c.ofs == var_a.ofs) { @@ -12966,6 +12966,7 @@ QCC_function_t *QCC_PR_ParseImmediateStatements (QCC_def_t *def, QCC_type_t *typ { //FIXME: should probably always take this path, but kinda pointless until we have relocs for defs QCC_RemapLockedTemps(f->code, numstatements); QCC_Marshal_Locals(f->code, numstatements); + QCC_WriteAsmFunction(f, f->code, f->firstlocal); //FIXME: this will print the entire function, not just the part that we added. and we'll print it all again later, too. should probably make it a function attribute that we check at the end. f->numstatements = numstatements - f->code; f->statements = qccHunkAlloc(sizeof(*statements)*f->numstatements);