[PATCH 3/9] simplify ((A & M) | B ) & M' even when (M & M') != 0

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

 



Currently, in simplify_and_or_mask(), the simplification
is only done when (M & M') == 0.

However it can be simplified anytime when (M & M') != M,
resulting in a smaller mask.

Allow the mask simplification when (M & M') != M.
---
 simplify.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/simplify.c b/simplify.c
index 6b813d4f9..6a68ee5b4 100644
--- a/simplify.c
+++ b/simplify.c
@@ -833,9 +833,12 @@ static int simplify_and_or_mask(struct instruction *insn, pseudo_t and, pseudo_t
 		return 0;
 	omask = def->src2->value;
 	nmask = omask & mask;
+	if (nmask == omask)
+		return 0;
 	if (nmask == 0)
 		return replace_pseudo(insn, &insn->src1, other);
-	return 0;
+	def->src2 = value_pseudo(nmask);
+	return REPEAT_CSE;
 }
 
 static int simplify_constant_mask(struct instruction *insn, unsigned long long mask)
@@ -854,7 +857,6 @@ static int simplify_constant_mask(struct instruction *insn, unsigned long long m
 	case OP_OR:
 		// Let's handle ((A & M') | B ) & M
 		// or           (B | (A & M')) & M
-		// when M' & M == 0
 		src1 = def->src1;
 		src2 = def->src2;
 		if (def_opcode(src1) == OP_AND)
-- 
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