* [PATCH] TRUNC(x) {==,!=} C --> AND(x,M) {==,!=} C
@ 2021-04-18 19:41 Luc Van Oostenryck
0 siblings, 0 replies; only message in thread
From: Luc Van Oostenryck @ 2021-04-18 19:41 UTC (permalink / raw)
To: linux-sparse; +Cc: Luc Van Oostenryck
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(+)
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);
--
2.31.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-04-18 19:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-18 19:41 [PATCH] TRUNC(x) {==,!=} C --> AND(x,M) {==,!=} C Luc Van Oostenryck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).