[PATCH] TRUNC(x) {==,!=} C --> AND(x,M) {==,!=} C

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 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




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux