[PATCH 2/3] simplify TRUNC(NOT(x)) --> NOT(TRUNC(x))

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

 



The goal is double:
1) be able to do the NOT operation on the smaller type
2) more importantly, give the opportunity to the TRUNC to
   cancel with a previous ZEXT if there is one.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 simplify.c                    | 15 +++++++++++++++
 validation/optim/trunc-not0.c |  1 -
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/simplify.c b/simplify.c
index 9e3514d838a9..b2311d397b23 100644
--- a/simplify.c
+++ b/simplify.c
@@ -2288,6 +2288,21 @@ static int simplify_cast(struct instruction *insn)
 			return replace_pseudo(insn, &insn->src1, def->src1);
 		}
 		break;
+	case OP_NOT:
+		switch (insn->opcode) {
+		case OP_TRUNC:
+			if (!one_use(src))
+				break;
+
+			// TRUNC(NOT(x)) --> NOT(TRUNC(x))
+			insn->opcode = OP_NOT;
+			def->orig_type = def->type;
+			def->opcode = OP_TRUNC;
+			def->type = insn->type;
+			def->size = insn->size;
+			return REPEAT_CSE;
+		}
+		break;
 	case OP_OR:
 		switch (insn->opcode) {
 		case OP_TRUNC:
diff --git a/validation/optim/trunc-not0.c b/validation/optim/trunc-not0.c
index febed165b0c4..882b446d9197 100644
--- a/validation/optim/trunc-not0.c
+++ b/validation/optim/trunc-not0.c
@@ -14,7 +14,6 @@ static _Bool ubar(uint64 a) { return (~(uint32) ~a) == (uint32)a; }
 /*
  * check-name: trunc-not0
  * check-command: test-linearize -Wno-decl $file
- * check-known-to-fail
  *
  * check-output-ignore
  * check-output-returns: 1
-- 
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