diff options
| author | Alexander Viro <viro@www.linux.org.uk> | 2004-07-23 22:35:40 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-07 21:02:17 -0700 |
| commit | 5b1132531e902676c9872ffc2ab80ee3aac40aab (patch) | |
| tree | d4b137f50471c099317d8aab5b76c3c2e30f3847 /compile-i386.c | |
| parent | 5023b2c4d6c1251dd4895e10c7eb93f45b20b42e (diff) | |
| download | sparse-dev-5b1132531e902676c9872ffc2ab80ee3aac40aab.tar.gz | |
[PATCH] comparison operations fix
simplify_int_binop() was completely broken for comparisons - there the
signedness of (converted) arguments can not be obtained from type of
result. IOW, we had all comparisons in constant expressions done as
signed ones.
Fixed by introducing new primitives for unsigned versions of
comparions (SPECIAL_UNSIGNED_LT, etc.) and remapping in evaluate_compare()
once we know the types. That also fixes similar mess in compile-i386 and
linearize.
Diffstat (limited to 'compile-i386.c')
| -rw-r--r-- | compile-i386.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/compile-i386.c b/compile-i386.c index 2c9bef75..596b47ae 100644 --- a/compile-i386.c +++ b/compile-i386.c @@ -1051,30 +1051,25 @@ static struct storage *emit_compare(struct expression *expr) struct storage *right = x86_expression(expr->right); 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; switch(expr->op) { - case '<': - if (is_signed) opname = "setl"; - else opname = "setb"; - break; - case '>': - if (is_signed) opname = "setg"; - else opname = "seta"; - break; + case '<': opname = "setl"; break; + case '>': opname = "setg"; break; case SPECIAL_LTE: - if (is_signed) opname = "setle"; - else opname = "setbe"; - break; + opname = "setle"; break; case SPECIAL_GTE: - if (is_signed) opname = "setge"; - else opname = "setae"; - break; - + opname = "setge"; break; case SPECIAL_EQUAL: opname = "sete"; break; case SPECIAL_NOTEQUAL: opname = "setne"; break; - + case SPECIAL_UNSIGNED_LT: + opname = "setb"; break; + case SPECIAL_UNSIGNED_GT: + opname = "seta"; break; + case SPECIAL_UNSIGNED_LTE: + opname = "setb"; break; + case SPECIAL_UNSIGNED_GTE: + opname = "setae"; break; default: assert(0); break; |
