Seeing as I've had all positive feedback on this, here's a more complete diff that I think is suitable for committing.
It does the following: 1. Converts movl $0, %e{ax,cx,dx,sp,si,di} to xorl %e{ax,cx,dx,sp,si,di}, %e{ax,cx,dx,sp,si,di} 2. Converts movq $0, %r{ax,cx,dx,sp,si,di} to xorl %e{ax,cx,dx,sp,si,di}, %e{ax,cx,dx,sp,si,di} There are two places where these idioms can be emitted, so it handles both cases. Here are some before and after .text size numbers: bin old new diff %reduction --- --- --- ---- ---------- tcc 328786 321358 7428 2.26 libtcc.a 307288 300252 7036 2.29 bcheck.o 23254 22801 453 1.95 bt-exe.o 4732 4550 182 3.85 bt-log.o 648 639 9 1.39 libtcc1.a 12678 12119 559 4.41 There is no change in compilation speed as far as I can measure. There is an additional third location where a mov $0, %eax can be emitted. It's in the form: mov $0, %eax jmp eb 05 mov $1, %eax -or- mov $1, %eax jmp eb 05 mov $0, %eax I could not find where this was happening, and the one place that looks like it would be the place seems not to be. I don't think it impedes the review and committing of this diff. And it'll give me something to do on a rainy day if no one else beats me to it :) At this point, I'd like any feedback on the diff below and/or encouragement to commit it to mob. Thanks. ~Brian diff --git a/x86_64-gen.c b/x86_64-gen.c index 81ec5d9..5085a0a 100644 --- a/x86_64-gen.c +++ b/x86_64-gen.c @@ -483,11 +483,21 @@ void load(int r, SValue *sv) } #endif } else if (is64_type(ft)) { - orex(1,r,0, 0xb8 + REG_VALUE(r)); /* mov $xx, r */ - gen_le64(sv->c.i); + if (sv->c.i == 0 && r < 8) { + o(0x31); /* xor r, r */ + o(0xc0 + REG_VALUE(r) * 9); + } else { + orex(1,r,0, 0xb8 + REG_VALUE(r)); /* mov $xx, r */ + gen_le64(sv->c.i); + } } else { - orex(0,r,0, 0xb8 + REG_VALUE(r)); /* mov $xx, r */ - gen_le32(fc); + if (fc == 0 && r < 8) { + o(0x31); /* xor r, r */ + o(0xc0 + REG_VALUE(r) * 9); + } else { + orex(0,r,0, 0xb8 + REG_VALUE(r)); /* mov $xx, r */ + gen_le32(fc); + } } } else if (v == VT_LOCAL) { orex(1,0,r,0x8d); /* lea xxx(%ebp), r */ @@ -1422,8 +1432,12 @@ void gfunc_call(int nb_args) } } - if (vtop->type.ref->f.func_type != FUNC_NEW) /* implies FUNC_OLD or FUNC_ELLIPSIS */ - oad(0xb8, nb_sse_args < 8 ? nb_sse_args : 8); /* mov nb_sse_args, %eax */ + if (vtop->type.ref->f.func_type != FUNC_NEW) { /* implies FUNC_OLD or FUNC_ELLIPSIS */ + if (nb_sse_args == 0) + o(0xc031); /* xor eax, eax */ + else + oad(0xb8, nb_sse_args < 8 ? nb_sse_args : 8); /* mov nb_sse_args, %eax */ + } gcall_or_jmp(0); if (args_size) gadd_sp(args_size); _______________________________________________ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel