From 99bf609861c3bc9ba313a81642988da92838c9e2 Mon Sep 17 00:00:00 2001 From: Luc Van Oostenryck Date: Sat, 13 Mar 2021 14:03:20 +0100 Subject: TRUNC(x) {==,!=} C --> AND(x,M) {==,!=} C It's not 100% clear than this is indeed a simplification but: 1) from a pure instruction count point of view, it doesn't make things worst 2) in most place where it applies, the masking is made redundant and is thus eliminated Signed-off-by: Luc Van Oostenryck --- simplify.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/simplify.c b/simplify.c index 9e3514d8..21c556e1 100644 --- a/simplify.c +++ b/simplify.c @@ -1392,6 +1392,20 @@ static int simplify_compare_constant(struct instruction *insn, long long value) break; } break; + case OP_TRUNC: + osize = def->orig_type->bit_size; + switch (insn->opcode) { + case OP_SET_EQ: case OP_SET_NE: + if (one_use(def->target)) { + insn->itype = def->orig_type; + def->type = def->orig_type; + def->size = osize; + def->src2 = value_pseudo(bits); + return replace_opcode(def, OP_AND); + } + break; + } + break; case OP_ZEXT: osize = def->orig_type->bit_size; bits = bits_mask(osize); -- cgit 1.2.3-korg