aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-02-04 12:21:24 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:06:19 -0700
commit7c1b75d0de6b3ad68fa40221a9b918d7fdd9e6fb (patch)
tree1f1cd8d5fdc025d8aea5defcec02ab3d25fa47f8 /simplify.c
parentSplit OP_CAST into signed, unsigned and FP casts. (diff)
downloadsparse-7c1b75d0de6b3ad68fa40221a9b918d7fdd9e6fb.tar.gz
sparse-7c1b75d0de6b3ad68fa40221a9b918d7fdd9e6fb.tar.bz2
sparse-7c1b75d0de6b3ad68fa40221a9b918d7fdd9e6fb.zip
Make simplification remove casts that change neither size nor sign.
Diffstat (limited to 'simplify.c')
-rw-r--r--simplify.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/simplify.c b/simplify.c
index 7a69906..8f9d814 100644
--- a/simplify.c
+++ b/simplify.c
@@ -553,12 +553,17 @@ static int simplify_memop(struct instruction *insn)
static int simplify_cast(struct instruction *insn)
{
+ struct symbol *orig_type;
int orig_size, size;
pseudo_t src;
if (dead_insn(insn, &insn->src, NULL, NULL))
return REPEAT_CSE;
- orig_size = insn->orig_type ? insn->orig_type->bit_size : 0;
+
+ orig_type = insn->orig_type;
+ if (!orig_type)
+ return 0;
+ orig_size = orig_type->bit_size;
size = insn->size;
src = insn->src;
@@ -575,6 +580,12 @@ static int simplify_cast(struct instruction *insn)
}
}
+ if (size == orig_size) {
+ int op = (orig_type->ctype.modifiers & MOD_SIGNED) ? OP_SCAST : OP_CAST;
+ if (insn->opcode == op)
+ goto simplify;
+ }
+
return 0;
simplify: