aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/compile-i386.c
diff options
authorJeff Garzik <jgarzik@redhat.com>2003-09-12 02:05:06 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:01:15 -0700
commit1ff814445ad900b41ae5325a6a996f5575d499bd (patch)
tree8eb5b80de3d19f426dd4786fdd0516208f168c17 /compile-i386.c
parentc17404ab0019bf20cbdc0ecbc298040a2af5e52a (diff)
downloadsparse-dev-1ff814445ad900b41ae5325a6a996f5575d499bd.tar.gz
[be] prefer "mov $0, %eax" to "xor %eax, %eax"
Diffstat (limited to 'compile-i386.c')
-rw-r--r--compile-i386.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/compile-i386.c b/compile-i386.c
index 4a5a1769..aab854e4 100644
--- a/compile-i386.c
+++ b/compile-i386.c
@@ -935,7 +935,7 @@ static struct storage *emit_compare(struct expression *expr)
{
struct storage *left = x86_expression(expr->left);
struct storage *right = x86_expression(expr->right);
- struct storage *new;
+ struct storage *new, *val;
const char *opname = NULL;
unsigned int is_signed = type_is_signed(expr->left->ctype); /* FIXME */
unsigned int right_bits = expr->right->ctype->bit_size;
@@ -967,7 +967,9 @@ static struct storage *emit_compare(struct expression *expr)
}
/* init EDX to 0 */
- insn("xor", REG_EDX, REG_EDX, "begin EXPR_COMPARE");
+ val = new_storage(STOR_VALUE);
+ val->flags = STOR_WANTS_FREE;
+ emit_move(val, REG_EDX, NULL, NULL);
/* move op1 into EAX */
emit_move(left, REG_EAX, expr->left->ctype, NULL);
@@ -1250,12 +1252,14 @@ static struct storage *emit_cast_expr(struct expression *expr)
static struct storage *emit_regular_preop(struct expression *expr)
{
struct storage *target = x86_expression(expr->unop);
- struct storage *new = new_pseudo();
+ struct storage *val, *new = new_pseudo();
const char *opname = NULL;
switch (expr->op) {
case '!':
- insn("xor", REG_EDX, REG_EDX, NULL);
+ val = new_storage(STOR_VALUE);
+ val->flags = STOR_WANTS_FREE;
+ emit_move(val, REG_EDX, NULL, NULL);
emit_move(target, REG_EAX, expr->unop->ctype, NULL);
insn("test", REG_EAX, REG_EAX, NULL);
insn("setz", REG_DL, NULL, NULL);