From 96ba4605faf09b27aa1cef72ab13f516fae11f8e Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 12 Jan 2011 23:33:51 +0900 Subject: [PATCH] Fix the micro-optimization that avoided emitting x = x The check was broken by alias defs. If a def is aliased, the alias must be checked. --- tools/qfcc/source/emit.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/qfcc/source/emit.c b/tools/qfcc/source/emit.c index bc2f3eb43..6c5515453 100644 --- a/tools/qfcc/source/emit.c +++ b/tools/qfcc/source/emit.c @@ -253,7 +253,7 @@ emit_function_call (expr_t *e, def_t *dest) static def_t * emit_assign_expr (int oper, expr_t *e) { - def_t *def_a, *def_b, *def_c; + def_t *def_a, *def_b, *def_c, *a, *b; opcode_t *op; expr_t *e1 = e->e.expr.e1; expr_t *e2 = e->e.expr.e2; @@ -288,7 +288,13 @@ emit_assign_expr (int oper, expr_t *e) } } def_b = emit_sub_expr (e2, def_a); - if (def_b != def_a) { + a = def_a; + if (a->alias) + a = a->alias; + b = def_b; + if (b->alias) + b = b->alias; + if (b != a) { op = opcode_find (operator, def_b->type, def_a->type, &type_invalid); emit_statement (e, op, def_b, def_a, 0);