Message ID | 20210418194135.56287-1-luc.vanoostenryck@gmail.com (mailing list archive) |
---|---|
State | Mainlined, archived |
Headers | show |
Series | TRUNC(x) {==,!=} C --> AND(x,M) {==,!=} C | expand |
diff --git a/simplify.c b/simplify.c index 9e3514d838a9..faf769b2f3cf 100644 --- a/simplify.c +++ b/simplify.c @@ -1392,6 +1392,19 @@ 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)) { + 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);
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 <luc.vanoostenryck@gmail.com> --- simplify.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)