[PATCH 6/9] move opcode test inside simplify_and_or_mask()

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

 



Calls to simplify_and_or_mask() are guarded by a test
checking if the operand is defined by an OP_AND.
However, this test can also be done inside the function.

Move opcode test inside simplify_and_or_mask() which simplify
the use of this function.
---
 simplify.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/simplify.c b/simplify.c
index 53dd4a2ad..ff2174388 100644
--- a/simplify.c
+++ b/simplify.c
@@ -826,10 +826,10 @@ static int simplify_seteq_setne(struct instruction *insn, long long value)
 
 static int simplify_and_or_mask(pseudo_t and, unsigned long long mask)
 {
-	struct instruction *def = and->def;
 	unsigned long long omask, nmask;
+	struct instruction *def;
 
-	if (!constant(def->src2))
+	if (DEF_OPCODE(def, and) != OP_AND || !constant(def->src2))
 		return 0;
 	omask = def->src2->value;
 	nmask = omask & mask;
@@ -845,7 +845,6 @@ static int simplify_constant_mask(struct instruction *insn, unsigned long long m
 	unsigned long long omask;
 	unsigned long long nmask;
 	struct instruction *def;
-	pseudo_t src1, src2;
 	int rc = 0;
 	int osize;
 
@@ -856,12 +855,8 @@ 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
-		src1 = def->src1;
-		src2 = def->src2;
-		if (def_opcode(src1) == OP_AND)
-			rc |= simplify_and_or_mask(src1, mask);
-		if (def_opcode(src2) == OP_AND)
-			rc |= simplify_and_or_mask(src2, mask);
+		rc |= simplify_and_or_mask(def->src1, mask);
+		rc |= simplify_and_or_mask(def->src2, mask);
 		return rc;
 	case OP_ZEXT:
 		osize = def->orig_type->bit_size;
-- 
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