[PATCH 08/13] simplify SETNE(AND(X,1),0) to AND(X,1)

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

 



Since the OP_SETCC instructions can only return a 0 or a 1,
a compare-not-equal-zero or compare-equal-1 is a no-op
if the operand have been masked with 1.

Remove the no-op comparison (if the size matches).

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

diff --git a/simplify.c b/simplify.c
index 839452b00..ae53e7ae7 100644
--- a/simplify.c
+++ b/simplify.c
@@ -713,6 +713,16 @@ static int simplify_seteq_setne(struct instruction *insn, long long value)
 	}
 	opcode = def->opcode;
 	switch (opcode) {
+	case OP_AND:
+		if (inverse)
+			break;
+		if (def->size != insn->size)
+			break;
+		if (def->src2->type != PSEUDO_VAL)
+			break;
+		if (def->src2->value != 1)
+			break;
+		return replace_with_pseudo(insn, old);
 	case OP_FPCMP ... OP_BINCMP_END:
 		// Convert:
 		//	setcc.n	%t <- %a, %b
diff --git a/validation/optim/mask1-setne0.c b/validation/optim/mask1-setne0.c
index 8810189cd..1e599dc80 100644
--- a/validation/optim/mask1-setne0.c
+++ b/validation/optim/mask1-setne0.c
@@ -16,7 +16,6 @@ int foo(struct s x)
 /*
  * check-name: mask1-setne0
  * check-command: test-linearize -Wno-decl $file
- * check-known-to-fail
  *
  * check-output-start
 foo:
-- 
2.18.0

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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